Search the Community
Showing results for tags 'run()'.
Found 2 results
Hi Only on some Windows 10 PCs do I get the issue that the Run() fails with the @SW_HIDE = Hidden window (or Default keyword) option. Not all Win10 machines, only some, but then consistently. I have put UAC to lowest level, no joy. As if the OS does not allow the hidden window to be created... Seems that @SW_MINIMIZE = Minimized window or @SW_MAXIMIZE = Maximized window does not suffer the same fate. I will have more info in a day or so. Anybody else with similar experience? Skysnake
I have a function that runs a DOS command and returns the output of the command, and it returns the correct data for some commands, bu tnot for others. I've narrowed it down to this: "HELP FIND" returns nothing "HELP DIR" returns several strings of help info. Here's my test code: #include <Constants.au3> test() Func test() Local $sSTDOUT, $cmd $cmd = "C:\Windows\System32\help.exe find" ;$cmd = "C:\Windows\System32\help.exe dir" $sSTDOUT = _RunDosCmd($cmd) ConsoleWrite("+++: $sSTDOUT ==>" & $sSTDOUT & "<==" & @CRLF) MsgBox(0, "INFO", "$sSTDOUT ==>" & $sSTDOUT & "<==") EndFunc ;==>test Func _RunDosCmd($sDosCmd) Local $cmd, $iPID, $sSTDOUT, $ar, $err $cmd = @ComSpec & ' /C ' & $sDosCmd ConsoleWrite("+++: $cmd = " & $cmd & @CRLF) ; Run the command, capturing the STDOUT data $iPID = Run($cmd, "", @SW_HIDE, $STDERR_MERGED) ; <== merge STDOUT and STDERR ; Success: the PID of the process that was launched. ; Failure: 0 and sets the @error flag to non-zero. $err = @error ConsoleWrite("+++: $err = " & $err & " after call to Run()" & @CRLF) ConsoleWrite("+++: $iPID = " & $iPID & " after call to Run()" & @CRLF) If ($err) Then ConsoleWrite("+++: Error returned by Run()" & @CRLF) Return ("") EndIf ; Wait until the process has closed using the PID returned by Run. ProcessWaitClose($iPID) ; Success: 1 and sets @extended to the exit code of the process. ; Failure: 0 if the wait timed out. On invalid PID the @error flag ; is set to non-zero and @extended is set to 0xCCCCCCCC. $err = @error ConsoleWrite("+++: @error = " & $err & " after call to ProcessWaitClose()" & @CRLF) ; Read the merged STDOUT/STDERR stream of the PID returned by Run. $sSTDOUT = "" While (1) $sSTDOUT &= StdoutRead($iPID) $err = @error If ($err) Then ExitLoop WEnd Return ($sSTDOUT) EndFunc ;==>_RunDosCmd