cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
DLee65
Level 13

LaunchAppAndWait with CMD and batch file

I am trying to execute a batch file after install using LaunchAppAndWait. The batch file is in the installation directory and references files within the install directory. However, when CMD starts it starts in the System directory, either System32 or SysWOW64 depending on the OS.

I have tried setting ChangeDirectory(sInstallDir); however, that has not worked.
According to the help documentation the option, LAAW_OPTION_NO_CHANGEDIRECTORY is obsolete.

What I would like to do is start the CMD window so that it is directory is INSTALLDIR. Then execute the batch file.

For some reason I thought that I could stack commands in the parameters and I tried to stack cd sInstallDir sBatchFile, but that did not work either.

Any ideas?
Labels (1)
0 Kudos
(1) Reply
DLee65
Level 13

I figured out how to stack commands to the command interpreter.

I needed to pass in the commands with an ampersand separator.

example:

cmdopt = "/C " + "cd " + sInstallDir + "&" + sFilePathName;

SprintfMsiLog("INFORMATION: Attempting to execute Registeritall.bat. CMD: %s, PARAM: %s.", cmdExecute, cmdopt);
nResult = LaunchAppAndWait(cmdExecute, cmdopt, LAAW_OPTION_WAIT);
if nResult != ERROR_SUCCESS then
SprintfMsiLog("ERROR: Failed to execute Registeritall.bat. Return value: %d", nResult);
endif;
0 Kudos