Jump to content

Can't read STDOUT for quser


Recommended Posts

Hi!

I'm triying to get the session id to close automatically a RDP session.

I tried doing this:

#RequireAdmin
#include <Constants.au3>
$DOS = Run('C:\Windows\System32\query.exe user', "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
;Run(@ComSpec & " /c " & 'Query User', "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
;Run(@ComSpec & " /c " & 'quser', "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
ProcessWaitClose($DOS)
$Message = StdoutRead($DOS)
MsgBox(0,'',$Message)

But the $Message is always empty, if I execute any of these commands in a cmd window, it works

Any idea on why is this falling? there is another way to get this info?

 

PS: Sorry for my english, i'm not native.

Link to comment
Share on other sites

#RequireAdmin
#include <Constants.au3>
#include <WinAPIFiles.au3>

_WinAPI_Wow64EnableWow64FsRedirection(FALSE)

Local $Message = ""
Local $DOS = Run('C:\Windows\System32\query.exe user', "", @SW_HIDE, $STDERR_MERGED)

Do
    $Message &= StdoutRead($DOS)
Until @error

MsgBox(0, '', $Message)

 

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...