VBScript,如何找到给定进程的所有者?

时间:2011-09-17 01:55:57

标签: process vbscript wmi

我正在尝试编写vbs来查找进程所有者。你能帮我吗?

1 个答案:

答案 0 :(得分:7)

我的google-fu很强大

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