DLee65
12-13-2013, 12:23 PM
I have a basic msi project in which I have an InstallScript custom action.
The custom action runs LaunchApplication and sets the working directory to INSTALLDIR
Now, I know that the paths are set correctly, because the actual batch file executes. So INSTALLDIR must be set correctly because I use that to obtain the path to the batch files.
However, unless the working directory is set properly, the batch files will always fail, because the batch files are written with only the names of idividual files inside of them, and CMD.exe tends to execute in the system32 context without the working directory set properly.
I have been at this for many days working on variations of this problem.
First I started by calling CMD.exe directly and passing in /C "<installdir>batchfile.bat". This process fails. Note that in each of these tests, the working directory for LaunchApplication is set to "INSTALLDIR", not the property name as I have it spelled out here, but the value of INSTALLDIR as received by MsiGetProperty inside of my InstallScript custom action. I just wanted to be clear here because some people read these things literally :)
I have tried adding quotes to the working directory using the following:
strINSTALLDIR = sInstallDir;
strWorkingDir = sInstallDir;
LongPathToQuote(strINSTALLDIR, TRUE);
LongPathToQuote(strWorkingDir, TRUE);
My command line is formatted as follows:
sFullPath = sInstallDir ^ sFile;
LongPathToQuote(sFullPath, TRUE);
nCmdResult = LaunchApplication(sFullPath, "",strWorkingDir, SW_NORMAL, 120000, LAAW_OPTION_WAIT);
When I ran this with the CMD prompt and the /K option, the context was showing CMD window was set to system32, not my strWorkingDir value. The MSI log definately shows that strINSTALLDIR is set correctly.
What am I missing in this puzzle?
Thanks.
The custom action runs LaunchApplication and sets the working directory to INSTALLDIR
Now, I know that the paths are set correctly, because the actual batch file executes. So INSTALLDIR must be set correctly because I use that to obtain the path to the batch files.
However, unless the working directory is set properly, the batch files will always fail, because the batch files are written with only the names of idividual files inside of them, and CMD.exe tends to execute in the system32 context without the working directory set properly.
I have been at this for many days working on variations of this problem.
First I started by calling CMD.exe directly and passing in /C "<installdir>batchfile.bat". This process fails. Note that in each of these tests, the working directory for LaunchApplication is set to "INSTALLDIR", not the property name as I have it spelled out here, but the value of INSTALLDIR as received by MsiGetProperty inside of my InstallScript custom action. I just wanted to be clear here because some people read these things literally :)
I have tried adding quotes to the working directory using the following:
strINSTALLDIR = sInstallDir;
strWorkingDir = sInstallDir;
LongPathToQuote(strINSTALLDIR, TRUE);
LongPathToQuote(strWorkingDir, TRUE);
My command line is formatted as follows:
sFullPath = sInstallDir ^ sFile;
LongPathToQuote(sFullPath, TRUE);
nCmdResult = LaunchApplication(sFullPath, "",strWorkingDir, SW_NORMAL, 120000, LAAW_OPTION_WAIT);
When I ran this with the CMD prompt and the /K option, the context was showing CMD window was set to system32, not my strWorkingDir value. The MSI log definately shows that strINSTALLDIR is set correctly.
What am I missing in this puzzle?
Thanks.