wisem2540 Posted July 18, 2014 Posted July 18, 2014 (edited) Hello all, I made a script so that I can run Powercfg from command line, and get some data, and it works fine. But when I add PSexec to the mix, autoit fails to get all of the output Script $Computer = "localhost" $iPID = Run (@ComSpec & " /k " & "C:\PsExec.exe \\" & $Computer & " powercfg /l", "",@SW_SHOW,0x2) ; Wait until the process has closed using the PID returned by Run. ProcessWaitClose($iPID) Local $sOutput = StdoutRead($iPID) MsgBox (0,"output", $sOutput) If I run it manually, I see all the output. Running it like this, I only get the first line which is something like "Active Power Scheme" Any input would be apreciated Edited July 18, 2014 by wisem2540
Gianni Posted July 18, 2014 Posted July 18, 2014 in the run command, change the 0x2 parameter (that is $STDOUT_CHILD) with 0x8 (that is $STDERR_MERGED) so you will also see (and catch) what happens on the error stream..... Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....
wisem2540 Posted July 18, 2014 Author Posted July 18, 2014 Very interesting indeed. So now here is what I get.... PsExec v2.11 - Execute processes remotely Copyright © 2001-2014 Mark Russinovich Sysinternals - www.sysinternals.com Existing Power Schemes (* Active) Connecting to localhost... Starting PSEXESVC service on localhost... Connecting with PsExec service on localhost... Starting powercfg on localhost... powercfg exited on localhost with error code 0. So maybe Its launching a different process?
Gianni Posted July 18, 2014 Posted July 18, 2014 (edited) ...... So maybe Its launching a different process? yes, it seems that psexec launches your command (powercfg /l) in another process, and doing so, the "stdout" of the last launched process, does not return back to the initial caller. Maybe the I/O redirection chain is not properly piped back and the stream is lost somewhere Edited July 18, 2014 by Chimp Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....
Solution jguinch Posted July 21, 2014 Solution Posted July 21, 2014 Redirects the output in a local file and reads the file : $sOutput = "" $Computer = "localhost" $res = RunWait(@ComSpec & " /c c:\PsExec.exe \\" & $Computer & " powercfg /l > " & @TempDir & "\powercfg.txt", "", @SW_HIDE) If $res = 0 Then $sOutput = FileRead(@TempDir & "\powercfg.txt") FileDelete(@TempDir & "\powercfg.txt") MsgBox(0, "", $sOutput) EndIf Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF
wisem2540 Posted July 21, 2014 Author Posted July 21, 2014 I dont know why I didnt think of this... it works! Thank you so much
jguinch Posted July 21, 2014 Posted July 21, 2014 Mark your post as solved if it is... Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF
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