Skip to content

Instantly share code, notes, and snippets.

@joenorton8014
Last active August 28, 2018 17:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joenorton8014/7133d5069407ff3b66cdb056fecc1864 to your computer and use it in GitHub Desktop.
Save joenorton8014/7133d5069407ff3b66cdb056fecc1864 to your computer and use it in GitHub Desktop.
dim list
Set list = CreateObject("System.Collections.ArrayList")
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery( _
"SELECT * FROM Win32_Process",,48)
For Each objItem in colItems
list.Add objItem.ProcessId
Next
list.Sort
For Each objitem in list
Wscript.echo "=========================="
Wscript.echo "PID Number: " & objitem
Wscript.echo "=========================="
Set objShare = objWMIService.Get("Win32_Process.Handle=" & objitem)
Set objOutParams = objWMIService.ExecMethod("Win32_Process.Handle=" & objitem , "GetOwner")
Wscript.Echo "Out Parameters: "
Wscript.echo "Domain: " & objOutParams.Domain
Wscript.echo "ReturnValue: " & objOutParams.ReturnValue
Wscript.echo "User: " & objOutParams.User
Wscript.echo ""
Next
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment