strComputer = "." Set colProcesses = GetObject("winmgmts:" & _ "{impersonationLevel=impersonate}!\\" & strComputer & _ "\root\cimv2").ExecQuery("Select * from Win32_Process") For Each objProcess in colProcesses Return = objProcess.GetOwner(strNameOfUser) If Return <> 0 Then Wscript.Echo "Could not get owner info for process " & _ objProcess.Name & VBNewLine _ & "Error = " & Return Else Wscript.Echo "Process " _ & objProcess.Name & " is owned by " _ & "\" & strNameOfUser & "." End If Nextin VFP it looks like this:
strComputer = "." loCIMV2 = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" + strComputer + "\root\cimv2") colProcesses = loCIMV2.ExecQuery("Select * from Win32_Process") For Each objProcess in colProcesses strNameOfUser = SPACE(140) Return = objProcess.GetOwner(strNameOfUser) If Return <> 0 Then ? "Could not get owner info for process " + objProcess.Name + CHR(13) + "Error = " + STR(Return) Else IF objProcess.name = "WINWORD" SET STEP ON ENDIF ? "Process " + objProcess.Name + " is owned by " + "\" + strNameOfUser + "." EndIf NextI'm not sure the first example works "as is" as the variable "strNameOfUser" was not declared, the help says the "GetOwner" method has 2 "output" variables. Anyhow ;), it's not working, the strNameOfUser is never filled althought the method call returns 0 (success). I tried pre-filling it with null, 0, "" and a x number of spaces, it remains untouched.