Skip to content

Instantly share code, notes, and snippets.

@joenorton8014
Created August 28, 2018 17:57
Show Gist options
  • Save joenorton8014/dbf6d12a12e5ef637b9be666448a8497 to your computer and use it in GitHub Desktop.
Save joenorton8014/dbf6d12a12e5ef637b9be666448a8497 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
Set objShare = objWMIService.Get("Win32_Process.Handle=" & objitem)
Set objOutParams = objWMIService.ExecMethod("Win32_Process.Handle=" & objitem , "GetOwner")
if objOutParams.User = "SYSTEM" Then
Wscript.echo "=========================="
Wscript.echo "PID Numnber: " & objitem
Wscript.echo "=========================="
Wscript.Echo "Out Parameters: "
Wscript.echo "Domain: " & objOutParams.Domain
Wscript.echo "ReturnValue: " & objOutParams.ReturnValue
Wscript.echo "User: " & objOutParams.User
Wscript.echo ""
End If
Next
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment