Reputation: 15574
I have two VB Scripts, say First.vbs and Second.vbs.
First.vbs calls Second.vbs each time some action/event happens.
I want to write a new VB Script, say Third.vbs, which terminates all the instances of First.vbs and Second.vbs including itself, Third.vbs.
Can anyone give some suggestion/reference?
Upvotes: 0
Views: 207
Reputation:
You can also use the following query:
"SELECT * FROM Win32_Process WHERE CommandLine LIKE '%wscript.exe%'"
Please note this may stop all the processes running in a machine, with the name wscript.exe.
Upvotes: 1
Reputation: 200503
Try this:
Set wmi = GetObject("winmgmts://./root/cimv2")
Sub TerminateScript(name)
qry = "SELECT * FROM Win32_Process WHERE CommandLine LIKE '%" & name & "%'"
For Each p In wmi.ExecQuery(qry)
p.Terminate
Next
End Sub
TerminateScript "Second.vbs"
TerminateScript "First.vbs"
WScript.Quit(0) 'terminate self
Upvotes: 1