1

I need a .vbs file to check if a specific process is active and (if it is) terminate it.

1
  • 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. Commented Oct 20, 2012 at 7:36

2 Answers 2

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 & "'") 
Sign up to request clarification or add additional context in comments.

2 Comments

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"
Set colProcessList = objWMIService.ExecQuery("SELECT * FROM Win32_Process WHERE Name = 'KMPlayer.exe'")
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 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.