Sub ProcessTerminate(Process) Const StrComputer = "." Set WshShell = CreateObject("WScript.Shell") Set ObjWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & StrComputer & "\root\cimv2") Set ProcessList = objWMIService.ExecQuery("SELECT * FROM Win32_Process WHERE Name = '" & Process & "'") For Each ObjProcess in ProcessList On Error Resume Next ObjProcess.Terminate Wscript.Echo "Process Terminated, ProcessId=" & ObjProcess.ProcessId & " (" & ObjProcess.Name & ")" Next End Sub ProcessTerminate "chrome.exe"
Friday, February 3, 2017
Windows - How to terminate process using VBScript
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment