PDA

View Full Version : Trying to capture the console output from LaunchAppAndWait



benduong
01-10-2006, 06:28 PM
Hi all,

Having read the online help I was led to believe the following code should give me the console output of my app in stdout.txt, but it does not:

szAppPath = SUPPORTDIR ^ "MyApp.exe";
if (Is(FILE_EXISTS, szAppPath)) then
LongPathToQuote(szAppPath, TRUE);
szCmdLine = szAppPath + " " + "-r";
LAAW_STARTUPINFO.dwFlags = LAAW_STARTUPINFO.dwFlags | STARTF_USESTDHANDLES;
OpenFileMode(FILE_MODE_APPEND);
CreateFile(nvFileHandle, "C:\\", "stdout.txt");
LAAW_STARTUPINFO.hStdOutput = nvFileHandle;
LAAW_PARAMETERS.bInheritHandles = TRUE;
LaunchAppAndWait("", szCmdLine, LAAW_OPTION_WAIT);
CloseFile(nvFileHandle);
endif;

I ran it in debug and stepped through the code to make sure MyApp.exe is found and that each line is executed. I checked and there is stdout.txt in C:\
but the file is blank. The same command run manually does give me output.

Have I misread the online help or what have I done wrong?

Thanks!
Ben

Ryan A
01-11-2006, 08:34 AM
You could append

"> c:\stdout.txt"

to the end of your command line.. without the quotes

chrishein
01-11-2006, 10:45 AM
If you're just looking for the result code you should be able to retrieve it from:
LAAW_PARAMETERS.nLaunchResult


Hope this helps,
Chris

mkauflin
09-21-2006, 08:39 AM
I had the same problem: the programm started, displayed the output on the window but did not write it to the file specified (I tried both ways, the ">" and LAAW_STARTUPINFO.dwFlags = LAAW_STARTUPINFO.dwFlags | STARTF_USESTDHANDLES; -> both had the same result)

I wrote an exe which does the job for me (contains all the logic) and I call this exe from IS; problem is solved