Question Locked

VBScript dynamicly end task

0 helpful
4 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I want to end a task with a VBScript. I found several nice scripts but they are all static, you have to manually change settings for each process you want to end. That would be nice if I had to end the same processes on a bunch of computers due to a virus but it does not work well in the practicle world.

I modified a script I found and it runs nice but it always tells me the remote computer is not available. Even with it is the local computer.

Here is the code I have so far...

Dim Process,RC
Dim Hostname, ProcessQ
Dim Confirm1, Confirm2
Hostname = InputBox ("What is the Hostname or IP Address of the Server?")
Confirm1 = MsgBox("You typed in " & Hostname & VbCrLf &_
"Is this correct?", 4, "Continue?")
If Confirm1 = vbYes Then
ProcessQ = InputBox ("What process would you like to stop?")
Confirm2 = MsgBox("You typed in " & ProcessQ & VbCrLf &_
"Is this correct?", 4, "Continue?")
If Confirm2 = vbYes Then
End If

For Each Process in GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & "Hostname").ExecQuery("select * from Win32_Process where Name=ProcessQ")
RC=Process.Terminate
Next
End If

4 replies

by Member 25348569

For Each Process in GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & Hostname).ExecQuery("select * from Win32_Process where Name='" & ProcessQ & "'")

Neil :)

Edit to add! The end quotes "'" look really crap because of the display font (it's different when you are creating the post and it looks OK then) and it goes:

where Name= & ProcessQ &

:)

Edited to add: If I don't get a thumb for this I will be really, really annoyed! X-(

by Member 25348569

That was so funny that I forgot to breath! Not!

Neil :p

Tell you, I saw that a post had been added and I thought "Another thumb! Another thumb!". But it was only you... :_|

Happy New Year, jd.

This discussion is closed to new replies.