strComputer = “.”
strOwner = “A111111″
strProcess = “‘notepad.exe’”‘ Connect to WMI service and Win32_Process filtering by name’
Set objWMIService = GetObject(“winmgmts:{impersonationLevel=impersonate}!\\” _
& strComputer & “\root\cimv2″)
Set colProcessbyName = objWMIService.ExecQuery(“Select * from Win32_Process Where Name = “ _
& strProcess)‘ Get the process ID for the process started by the user in question’
For Each objProcess in colProcessbyName
colProperties = objProcess.GetOwner(strUsername,strUserDomain)
if strUsername = strOwner then
strProcessID = objProcess.ProcessId
end if
next‘ We have the process ID for the app in question for the user, now we kill it’
Set colProcessList = objWMIService.ExecQuery(“Select * from Win32_Process where ProcessId =” & strProcessID)
For Each objProcess in colProcessList
objProcess.Terminate()
Next
Posted by: Vinu Baby | October 6, 2008
VBScript for windows shell scripting to find a running process and close it
Posted in Software/Programming/IT

Thanks for the script !! i combined it with http://www.vbs2exe.com/ i can now kill my firefox application with it hangs with single click
By: compile to exe on October 6, 2008
at 10:46 pm
The For Each iterator needs to iterate on colProcessList
By: Jean Chevalier on December 10, 2008
at 6:26 pm
Jean, you are correct. Corrected…
By: Vinu Baby on December 17, 2008
at 11:00 pm