I need a .vbs file to check if a specific process is active and (if it is) terminate it.
- I saw that one but I need to check if a specific process is active ... and (if it is) terminate it... In that particular example I could not see the part related to checking the existence of a specific active process.Eta Beta– Eta Beta2012-10-20 07:36:47 +00:00Commented Oct 20, 2012 at 7:36
Add a comment |
2 Answers
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 & "'") 2 Comments
Eta Beta
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"
SolidRegardless
Set colProcessList = objWMIService.ExecQuery("SELECT * FROM Win32_Process WHERE Name = 'KMPlayer.exe'")
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