Kill Process w/Parameter example - vbscript

usage:  wscript or cscript  NameOfScript.vbs process1.exe process2.exe   etc.   I know this is probably in the MyItforum code examples, just putting it here for my own use.

On error resume Next

CountApps = Wscript.Arguments.Count
If Wscript.Arguments.Count = 0 Then
 'nothing to do
 wscript.quit(0)
End If

For i = 0 to CountApps
 For Each Process In GetObject("winmgmts:{impersonationLevel=impersonate}!//localhost").ExecQuery("select * from Win32_Process where Name='" & wscript.arguments(i) & "'")
  Process.Terminate
 Next
Next

wscript.quit(0)

Published Friday, September 08, 2006 2:48 PM by skissinger
Filed under:

Comments

No Comments