Wednesday, October 13, 2010

VBS Find owner of a given process

This code illustrates the owner of a given process on a remote machine. It takes a process (explorer.exe) and tells you the owner of it.  I used this code for my Outlook Cache Mode disable script. 


Set objWMIService = GetObject("winmgmts:"  & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") 


Set colProc = objWmiService.ExecQuery("Select Name from Win32_Process" & " Where Name='explorer.exe' and SessionID=0") 

 If colProc.Count > 0 Then 
  For Each oProcess In colProc 
    oProcess.GetOwner sUser, sDomain 
  Next 
 End If 


lngRtn = objRegistry.EnumKey(HKEY_USERS, "", arrRegKeys) 

No comments:

Post a Comment

Generating "Always On Top" NSWindow in macOS across all detected displays

Also: Using UIKit & Cocoa Frameworks using Objective-C In m acOS or OS X , written in either Objective-C or Swift  Langues, you m...