Is there any way to kill a wscript.exe (windows process for vb script) from another VBScript (not from the currently executing wscript)?
If I create a script like this:
Set s = CreateObject("WScript.Shell")
s.Run "taskkill /im wscript.exe", , True
instead of killing the former script, this will kill itself.
I'd recommend using WMI for selecting and terminating the processes. Something like this should work:
Set wmi = GetObject("winmgmts://./root/cimv2")
qry = "SELECT * FROM Win32_Process WHERE Name='wscript.exe' AND NOT " & _
"CommandLine LIKE '%" & Replace(WScript.ScriptFullName, "\", "\\") & "%'"
For Each p In wmi.ExecQuery(qry)
p.Terminate
Next
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With