Is there a way to capture the output written to the console from a Run program statement?
Printable View
Is there a way to capture the output written to the console from a Run program statement?
Mark,
"Run Command Line" is a wrapper around the CreateProcess API. In Windows, you always use ">" to redirect output from a console app to a text file.
Hope this helps.
Friedrich
And then the text file can be read back into SetupBuilder?
Yes. For example, via the "Handle Text File Operation..." script function.
Friedrich
Just LOOP through the file and then process the lines. Not sure what you are trying to do with the output result. Are you looking for specific error messages from the console application?
Friedrich
Kind of, we're just looking to display the contents to the user. We have a secondary install as part of our application and we found that when the secondary installer fails, it dumps the details of the error out to the console. So, we'd like to grab that and display it so we have some idea what went wrong. All we get right now is the not-helpful error code number returned back to SetupBuilder.
Okay. Then LOOP through the file and process the lines (look for error codes or something like that; e.g. using "Handle String Operations..."). Or just display the result.txt as a whole (using notepad or another default app).
Friedrich
Ok, that all works. Now the issue is that "Run Command Line" always returns error code 0, even if the installer that was run reported an error. Is this something that I'll have to handle manually?
Mark,
It returns "0" because the executable started without any problem (operation succeeded).
Return Values - If the function succeeds, the %_SB_ERRORCODE% return value is zero.
To catch the exit code (if the application returns any; not all do), you have to use "Run Program...".
BTW, if you need a demo project, just let me know.
Friedrich