VBScript to Kill a Process

This worked great for me. Just use as function and kill as many processes as you like.

For more such stuff regarding packaging, visit my blog and follow it for more updates:



KillProc "abc.exe"

Sub KillProc( myProcess )    

Dim blnRunning, colProcesses, objProcess    

blnRunning = False    

Set colProcesses = GetObject("winmgmts:{impersonationLevel=impersonate}").ExecQuery( "Select * From Win32_Process", , 48 )    

For Each objProcess in colProcesses        

If LCase( myProcess ) = LCase( objProcess.Name ) Then             ' Confirm that the process was actually running             blnRunning = True             ' Get exact case for the actual process name            

 myProcess  = objProcess.Name             ' Kill all instances of the process            


 End If    


 If blnRunning Then        

Do Until Not blnRunning            

 Set colProcesses = GetObject("winmgmts:{impersonationLevel=impersonate}").ExecQuery( "Select * From Win32_Process Where Name = '"& myProcess & "'" )            

WScript.Sleep 100 'Wait for 100 MilliSeconds            

If colProcesses.Count = 0 Then 'If no more processes are running, exit loop                

 blnRunning = False            

End If        


End If

End Sub


  • Thanks, useful. - Erroneus 10 years ago
  • Very helpful, thank you! - bkelly 10 years ago
  • This is a great tool. Thanks - ohiosoundguy 10 years ago
  • buton_onclick from an html pagecan trigger this .vbs script? How? - xavierantony 6 years ago
  • Good one. - apptopack 6 years ago
This post is locked
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ