We help IT Professionals succeed at work.

How to end a process running as a specific user

Last Modified: 2012-06-27
I need to end a process on a remote server that is currently running under a particular username.  I found a script on the Computer Performance website that can end a process, but it kills all instances of the process.  I need to end just one process running under a specific user like Administrator.  

Is this possible?

Code found on Computer Performance website, credit to Guy Thomas.
' ProcessKillRemote.vbs
' Sample VBScript to kill a program
' Author Guy Thomas http://computerperformance.co.uk/
' Version 2.9 - December 2005
' ------------------------ -------------------------------' 
Option Explicit
Dim objWMIService, objProcess, colProcess
Dim strComputer, strProcessKill, strInput 
strProcessKill = "'calc.exe'" 
' Input Box to get name of machine to run the process
    strComputer = (InputBox(" ComputerName to Run Script",_
    "Computer Name"))
    If strComputer <> "" Then
    strInput = True
    End if
Loop until strInput = True
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _ 
& strComputer & "\root\cimv2") 
Set colProcess = objWMIService.ExecQuery _
("Select * from Win32_Process Where Name = " & strProcessKill )
For Each objProcess in colProcess
WSCript.Echo "Just killed process " & strProcessKill _
& " on " & strComputer
' End of WMI Example of a Kill Process

Open in new window

Watch Question

This one is on us!
(Get your first solution completely free - no credit card required)
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.