I need a .vbs file to check if a specific process is active and (if it is) terminate it.
Asked
Active
Viewed 7,100 times
2 Answers
0
Same as this thread?
How to terminate process using VBScript
Except that you just change the following line:
Set colProcessList = objWMIService.ExecQuery("SELECT * FROM Win32_Process WHERE Name = 'Process.exe'")
to
Set colProcessList = objWMIService.ExecQuery("SELECT * FROM Win32_Process WHERE Name = '" & strMyProcess & "'")

Community
- 1
- 1

SolidRegardless
- 427
- 3
- 17
-
I did replace that line as you suggested but I must have done something wrong. Could you please tell me if/how the section **& strMyProcess &** needs to be edited assuming I want to kill a process called "KM Player.exe" – Eta Beta Oct 20 '12 at 17:45
-
Set colProcessList = objWMIService.ExecQuery("SELECT * FROM Win32_Process WHERE Name = 'KMPlayer.exe'") – SolidRegardless Oct 21 '12 at 13:58
0
myProcess="chrome.exe" 'repleace chrome.exe with your process name
Set Processes = GetObject("winmgmts:").InstancesOf("Win32_Process")
For Each Process In Processes
If StrComp(Process.Name, myProcess, vbTextCompare) = 0 Then 'check if process exist
Process.Terminate() 'kill the process you find
End If
Next

hollopost
- 569
- 9
- 28