Nil B
Nil B

Reputation: 305

VBScript, how to I find an owner of a given process?

I am trying to write vbs to find owner of process. Can you please help me?

Upvotes: 1

Views: 5421

Answers (1)

billinkc
billinkc

Reputation: 61221

My google-fu is strong

Microsoft Windows 2000 Scripting Guide - Determining Process Owners

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
 & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colProcessList = objWMIService.ExecQuery _
 ("SELECT * FROM Win32_Process")
For Each objProcess in colProcessList
 colProperties = objProcess.GetOwner(strNameOfUser,strUserDomain)
 Wscript.Echo "Process " & objProcess.Name & " is owned by " _
 & strUserDomain & "\" & strNameOfUser & "."
Next

Upvotes: 7

Related Questions