
0_david.a.eibeck asked a question.
How to use LaunchApplication function?
I need to call a command line function from an installscript based project and redirect the output. My attempts to use the LaunchApplication function in my main project weren't working so I created the following simplistic test case which still doesn't work.
I created a brand new default installscript project. I then added the following code:
MessageBox("Before LaunchApplication", INFORMATION);
nResult = LaunchApplication( "dir", ">> dir.txt", "C:\\data\\junk\\", SW_HIDE, 100, LAAW_OPTION_WAIT );
if(nResult < ISERR_SUCCESS)
then
MessageBox("Warning: App Failed.", INFORMATION);
abort;
else
MessageBox("App Succeeded.", INFORMATION);
abort;
endif;
The first message box displays and then I always get the App Failed warning and the app didn't run because there is no dir.txt file.
I'm sure I'm missing something obvious, but can't see it. Any help would be appreciated.
nResult = LaunchApplication( WINSYSDIR ^ "cmd.exe", "/c dir >> dir.txt", "C:\\data\\junk", SW_HIDE, 100, LAAW_OPTION_WAIT );
Just make sure that you really want to use ">>" (which appends to the file) instead of just ">" (which overwrites/creates a new file).
HTH