Question

Locked

VBScript dynamicly end task

By 1RealTruth ·
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

This conversation is currently closed to new comments.

4 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Answers

Collapse -

You've quotes where you shouldn't have them and no quotes where you should

by neilb@uk In reply to VBScript dynamicly end ta ...

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=<single><double> & ProcessQ & <double><single><double>

:)

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

Collapse -

Just curious

by jdclyde In reply to You've quotes where you s ...

can I quote you on that? ;\

Collapse -

Ha ha ha!

by neilb@uk In reply to Just curious

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

Neil

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.

Back to Networks Forum
4 total posts (Page 1 of 1)  

Related Discussions

Related Forums