Hi,
I'm looking through the list of processes via WMI.
Is it possible to find out the name of the user on whose behalf the process is opened?
driessen wrote:Hi,
Why don't you use this function : WNetGetUser()
Good luck.
FUNCTION TstUser()
LOCAL cDest := "procown.ps1"
LOCAL nHndl
nHndl := fCreate( cDest )
fClose( nHndl )
IF ( nHndl := fOpen( cDest, 17 ) ) != -1 // write+exclusive
fWrite( nHndl, [$proc = Get-CimInstance Win32_Process -Filter "name = 'notepad.exe'"] + HB_OsNewline() )
fWrite( nHndl, [Invoke-CimMethod -InputObject $proc -MethodName GetOwner >procown.txt] + HB_OsNewline() )
fClose( nHndl )
ENDIF
WinExec( "powershell.exe -windowstyle hidden -File procown.ps1" )
RETURN NIL
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: Google [Bot] and 99 guests