I have developed and uploaded a "catch exit code" demo for you:
http://www.lindersoft.com/forums/sho...8240#post78240
Friedrich
I have developed and uploaded a "catch exit code" demo for you:
http://www.lindersoft.com/forums/sho...8240#post78240
Friedrich
So, is there a way to run an external program, get the return code and the console output?
This should do it:
http://www.lindersoft.com/forums/sho...8220#post78220
The standard ">" Windows command redirects output from a console app to a text file and then just catch the exit code (if the app returns any).
The %_SB_ERRORCODE% return value can also hold the last exit code returned by the executable associated with the work item on its last run.
The %_SB_RETURNEX% variable holds the error code provided by the GetLastError Windows API if the CreateProcess function failed. It holds a system error code if a call to the ShellExecuteEx API failed.
Friedrich
Right, but I seem to be caught in a no-win situation with the external installer I'm running.
"Run Program" returns the error code back to SetupBuilder, but I can't get the console output: the ">" operator doesn't work.
"Run Command Line" generates the console output, but doesn't return the error code to SetupBuilder.
">" definitely works because it is a Windows "switch" ;-)
Friedrich
It has nothing to do with SetupBuilder's "Run Program" statement. The statement is just a wrapper around CreateProcess or ShellExecuteEx. Windows handles all the ">" redirection behind the scenes.
See attached screenshots. This "Run Program" function calls the good old PKUNZIP.EXE from 1993 and redirects the console output to the RESULT.TXT file.
Friedrich
Ok, not sure what I'm doing wrong then. My Run Program command looks a lot like the one you have above. The command line parameters are really long, is there some sort of "hidden character limit" I'm running into. If I take the exact same line and run it manually in a command window, the console output is redirected properly. Running the same command through SetupBuilder doesn't redirect the console output.
Please note that there is a fundamental difference between running an application from an OS "Command Prompt" and via the CreateProcess or ShellExecuteEx API !!!
BTW, the comment line limit is 1,024 bytes.
Friedrich
Mark,
I have created a simple quick-and-dirty demo for you on how to catch the return code and redirect console messages into out.txt (from a "Run Program..." command):
http://www.lindersoft.com/projects/markd.zip
Unzip the archive and compile and RUN the "MarkD.sb8" project file. It will launch a dummy "console1.exe" and displays its exit code (should display "951"). The redirection writes "Hello, this is a test output from a Win32 console app." to a "out.txt" ASCII text file. This method "should" work fine with DOS, Win32/64 and MFC console apps. But no guarantee because it depends on a secret/undocumented Windows feature
Friedrich
There are currently 1 users browsing this thread. (0 members and 1 guests)