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

前端 未结 1 685
抹茶落季
抹茶落季 2021-01-23 10:56

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

相关标签:
1条回答
  • 2021-01-23 11:33

    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
    
    0 讨论(0)
提交回复
热议问题