Retrieve ouput Info/error from LaunchAppAndWait
I'm new with installshield, I want to refactor my current Wix installer.
I have several command to launch ( like java.exe, perl.exe, .bat ...).
With LaunchAppAndWait the command is launch but return the exit code -1 ...
The most important part is I can't retrieve the output info or error.
If I put the line SprintfMsiLog("ERROR_OUTPUT : %s",INFORMATION); that spent a lot of time to retrieve nothing...
Anyone can help, this part is very important to validate the refactoring ? Below my code
nExitCode = LaunchAppAndWait( perlDir+"perl\\bin\\perl.exe", args , LAAW_OPTION_HIDDEN );
SprintfMsiLog("ExitCode : %d", nExitCode);
if nExitCode < 0 then
//SprintfMsiLog("ERROR_OUTPUT : %s",INFORMATION);
//SprintfMsiLog("INFO_OUTPUT : %s",INFORMATION);
Hi @gdeclerck ,
Since LaunchAppAndWait calls the following:
LaunchApplication( szProgram, szCmdLine, "", LAAW_STARTUPINFO.wShowWindow, LAAW_PARAMETERS.nTimeOut, nOptions | LAAW_OPTION_CHANGEDIRECTORY | LAAW_OPTION_FIXUP_PROGRAM );
If the application cannot be launched, the LAAW_PARAMETERS system variable’s nLaunchResult member contains the result of calling the Windows API function GetLastError after the CreateProcess or ShellExecuteEx call. If the function is successful and the LAAW_OPTION_WAIT option was specified, the LAAW_PARAMETERS system variable’s nLaunchResult member contains the return code of the launched application.
For more details:
Pseudo Code would be:
setuppath = SUPPORTDIR ^ "setup.exe"; msdecmd = "<setup.exe options go in here>"; LaunchAppAndWait(setuppath, msdecmd, LAAW_OPTION_WAIT); if (LAAW_PARAMETERS.nLaunchResult != 0) then MessageBoxEx( "MSDE 2000 failed to install.", "Install", SEVERE ); abort; endif;
Hope it helps,
Sorry it doesn't work, I try with a more easier example but without any success.
To simplify I launch a directory creation by CLI. I want to execute the command and retrieve the error output message when the directory already exist.
I may have a misunderstanding about the LaunchApplication function because I try a lot of parameters but nothing works.
Maybe there is an other way to call a command and retrieve the ouput than installscript ?
Here the code :
function TestIS(hMSI) // To Do: Declare local variables. STRING sysDir; STRING args; NUMBER nvSize, nExitCode; begin if MSICONDITION_TRUE = MsiEvaluateCondition(hMSI, "Not Installed") then //Initialize variables nvSize = 256; MsiGetProperty (hMSI, "SystemFolder", sysDir, nvSize); args = " mkdir D:\Test\ "; LaunchAppAndWait( sysDir+"cmd.exe", args,LAAW_OPTION_WAIT); SprintfMsiLog("ExitCode : %d",LAAW_PARAMETERS.nLaunchResult); if (LAAW_PARAMETERS.nLaunchResult != 0) then MessageBoxEx( "MSDE 2000 failed to install.", "Install", SEVERE ); abort; endif; return ERROR_SUCCESS; endif; end;