Thursday 26 April 2018

VB Script: Kill multiple processes

Sometimes we may need to kill the running process to proceed for uninstallation of an application without any issues.

Script:
Option Explicit
'On Error Resume Next
Dim objShell, X, strProcesses

Set objShell = CreateObject("WScript.Shell")

strProcesses = Array(_
"notepad.exe",_
"calc.exe",_
"winword.exe",_
"excel.exe")

For X = 0 to Ubound(strProcesses)
objShell.Run "%COMSPEC% /c TASKKILL.EXE /F /IM """ & strProcesses(X) & """ /T ", 0, True
Next

Set objShell = Nothing


NOTE: For examples, used Notepad,Calculator,Word and Excel process. replace the process name as per your needs in the array.

No comments:

Post a Comment