I wrote a NSIS script which copies two MSI files to $INSTDIR\Installers directory and then execute them, it's pretty easy and following is the code
1 2 3 4 5 |
SetOutPath $INSTDIR\Installers File "Installers\SqlLocalDB.msi" File "Installers\OutsideX64.msi" ExecWait "msiexec /i Installers\OutsideX64.msi" ExecWait "msiexec /i Installers\SqlLocalDB.msi" |
Unfortunately above code will not work and it's saying NSIS cannot find these two msi files, but I'm sure they existed!
Then I tried to put $INSTDIR at beginning of the path
1 |
ExecWait "msiexec /i $INSTDIR\Installers\OutsideX64.msi" |
Now a MSI Help Dialog pops up with information about how to use msiexec command.. Apparently it failed again.
To solve this issue, we need call SetOutPath before ExecWait, like following
1 2 3 4 5 6 7 |
SetOutPath $INSTDIR\Installers File "Installers\SqlLocalDB.msi" File "Installers\OutsideX64.msi" SetOutPath $INSTDIR ExecWait "msiexec /i Installers\OutsideX64.msi" ExecWait "msiexec /i Installers\SqlLocalDB.msi" |
The first three lines will copy SqlLocalDB.msi and OutsideX64.msi files to $INSTDIR\Installers, and the last three lines will install MSI files at $INSTDIR\Installers.
It's because that ExecWait (Exec, ExecShell) command will use $OUTDIR as working directory, and this path can be set by SetOutPath command (By default $OUTDIR is set to $INSTDIR).
If we don't call SetOutPath command explicitly before ExecWait, its working directory will be $INSTDIR\Installers, and it will try to install MSI files under $INSTDIR\Installers\Installers directory, which is apparently wrong.
(And this guy had same problem as well http://stackoverflow.com/questions/17105455/install-sql-server-2008-r2-express-sp2-with-nsis)