Reputation: 342
I am installing 3 msi files from 2 batch files. The first batch file finds the msi location and writes the log to my desired location
pushd %~dp0..\%VERSION%\MSIFOLDER\
msiexec /i "InstallMe.msi" /qn TARGETDIR="%x32%" TARGET64DIR="%x64%" /L*v "%~dp0Scripts\Logs\InstallMe.log"
msiexec /i "InstallMe2.msi" /qn TARGETDIR="%x32%" TARGET64DIR="%x64%" /L*v "%~dp0Scripts\Logs\InstallMe2.log"
popd
The second batch file finds the msi location (same as batch1) and writes the log to my desired location(same loc as batch1)
pushd %~dp0..\%VERSION%\MSIFOLDER\
msiexec /i "InstallMe3.msi" /qn TARGETDIR="%Target_PATH%\InstallMe3" /L*v "%~dp0..\..\BatchFileFolder\Scripts\Logs\InstallMe3.log"
popd
however, notice the different pathing to the log files of batch1 and batch2
It seems that pushd in batch1 does not set the path im pushd into as current working dir as the log %~dp0
still points to where the batch file lives
In batch2 it works as I expect it... I am really baffled how, basically identical commands have different behavior and cannot find out what causes it.
on top of both files i have SETLOCAL EnableDelayedExpansion
and
SETLOCAL EnableExtensions
Another thing worth mentioning is that if the 3 MSIs are called from 1 batch the pushd behaves correctly i.e. as batch2 when writing the log file to the /L*v "%~dp0..\..\BatchFileFolder\Scripts\Logs\InstallMe3.log"
path. But when I separate those 3 in 2 batch files .. they behave differently?!
Important: The reason I am using pushd is, I cannot install msi
files with relative path.
Any ideas and help would be highly appreciated.
|
+ ContainerDir
| +---MSIFilesRootDir [%VERSION%]
| | +---MSIFilesDir [%~dp0..\%VERSION%\MSIFilesDir]
| | InstallMe1.msi
| | InstallMe2.msi
| | InstallMe3.msi
| |
| +---BatchFileFolder [%~dp0]
| | BatchFile.bat
| | \---Scripts [%~dp0Scripts]
| | \---Logs [%~dp0Scripts\Logs]
| | InstallMe1.log
| | InstallMe2.log
| | InstallMe3.log
| |
This is the folder and file structure
Upvotes: 0
Views: 551
Reputation: 38613
Does this enable you to visualise things? I have added some information inside square brackets to help.
|
\---SomeDir [%~dp0..\..]
+---ContainerDir [%~dp0..]
| +---MSIFilesRootDir [%~dp0..\%VERSION%]
| | \---MSIFilesDir [%~dp0..\%VERSION%\MSIFilesDir]
| | InstallMe.msi [%~dp0..\%VERSION%\MSIFilesDir\InstallMe.msi]
| | InstallMe2.msi [%~dp0..\%VERSION%\MSIFilesDir\InstallMe2.msi]
| | InstallMe3.msi [%~dp0..\%VERSION%\MSIFilesDir\InstallMe3.msi]
| |
| \---BatchDir [%~dp0]
| | BatchFile.bat [%0]
| |
| \---Scripts [%~dp0Scripts]
| \---Logs [%~dp0Scripts\Logs]
| InstallMe.log [%~dp0Scripts\Logs\InstallMe.log]
| InstallMe2.log [%~dp0Scripts\Logs\InstallMe2.log]
|
\---BatchFileFolder [%~dp0..\..\BatchFileFolder]
\---Scripts [%~dp0..\..\BatchFileFolder\Scripts]
\---Logs [%~dp0..\..\BatchFileFolder\Scripts\Logs]
InstallMe3.log [%~dp0..\..\BatchFileFolder\Scripts\Logs\InstallMe3.log]
You can create something like this using Tree
with options /A
and /F
, (enter Tree /?
at the Command Prompt for usage information)
Upvotes: 1