View

VBScript : How to kill a Windows process

Function KillProcess(strProcessName)
	Dim oProcess
	KillProcess = False
	For Each oProcess in GetObject("winmgmts:").InstancesOf("Win32_Process")
		If InStr(UCase(strProcessName), UCase(oProcess.Name)) <> 0 Then
			oProcess.Terminate()
			KillProcess = True
			Exit Function
		End If
	Next
End Function

MsgBox KillProcess("Notepad.exe")

You may also like