Level 2

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)
MessageBox("Warning: App Failed.", INFORMATION);
MessageBox("App Succeeded.", INFORMATION);

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.
Labels (1)
0 Kudos
2 Replies
Level 7

I think this might be what you are looking for:

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).

0 Kudos
Level 2

Thanks, I had already figured out that my example was a little bogus since dir is a built in shell command and not a separate exe but hadn't yet figured out how to get the redirector to work with an exe file call. Your cmd.exe \c solution is exactly what I needed. Much appreciated.
0 Kudos