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"
Showing posts with label List Running Processes. Show all posts
Showing posts with label List Running Processes. Show all posts
Friday, February 3, 2017
Windows - How to terminate process using VBScript
VBScript Get List Of Running Processes And Executable Path
Dim Service, Process Set Service = GetObject ("winmgmts:") For each Process in Service.InstancesOf ("Win32_Process") Wscript.Echo Process.Name & ": " & Process.ExecutablePath Next
Subscribe to:
Posts (Atom)