J03Z Posted February 8, 2010 Posted February 8, 2010 Hey, I need a little direction with syntax. I am writting a script that basically connects to a remote computer and retrieves the currently logged in user of that computer and returns that output to a label. Example. _SET() $inputText = GUICtrlRead($InputData) $Set = True $PID = run(@ComSpec & " /c psloggedon.exe \\" & $inputText,@WorkingDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) $line = stdoutRead($PID) ConsoleWrite($line & @CRLF) For some reason I am not able to pull down the information. I can type the command "psloggedon \\computername" in a normal command prompt and see the currently logged on user. Its my understanding that the @comSpec is an autoit command line interperter ?. I have read through the forum and help document and I guess I just need a little more direction around this information. Any help would be greatly appreciated.
Steveiwonder Posted February 8, 2010 Posted February 8, 2010 (edited) I can't help you regarding @ComSpec but you can try this... $logfile = "C:\t.txt" run(@ComSpec & " /c psloggedon.exe \\" & $inputText & " > " & $logfile) $fOpen = FileOpen($logfile, 0) $result = FileRead($fOpen) ConsoleWrite($result) Edited February 8, 2010 by Steveiwonder They call me MrRegExpMan
KaFu Posted February 8, 2010 Posted February 8, 2010 Try something like this: #include <Constants.au3> $inputText = InputBox("Enter Client","Enter Client") if @error then Exit $PID = run(@ComSpec & " /c psloggedon.exe \\" & $inputText,@WorkingDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) $line = "" While 1 $line &= StdoutRead($PID) If @error Then ExitLoop Wend MsgBox(0,"Logged in user","Logged in user on" & @crlf & $inputText & @crlf & "is" & @crlf & $line) ConsoleWrite($line & @CRLF) OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2025-May-18) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16)
J03Z Posted February 9, 2010 Author Posted February 9, 2010 Thanks guys for all the help!!! I was able to get the major problem resolved.. just a few minor things I will reasearch. Thanks once again.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now