Search code examples
windows-installernsis

NSIS - msiexec /i fails with code 1619 if I call SetOutPath


ExecWait "msiexec /i myinstaller.msi /qn" $0

That's all I'm calling in my script. (The /qn is for silent installation without popping up any progress window, I've also tested without it).

It fails with an msiexec error code of 1619-This installation package could not be opened. Verify that the package exists and that you can access it, or contact the application vendor to verify that this is a valid Windows Installer package.

The same msiexec call works fine on the commandline, or if I write a basic NSIS script that does nothing else- which means it's not because of NTFS permissions that a Google search throws up.

Therefore, it must be something else in my main installer script. After commenting out nearly everything in my script to isolate the cause:

SetOutPath "$INSTDIR\Some directory"

If I comment this section out and don't set an output path, everything works fine. What on earth is going on? Why should this interfere with the msiexec call?

Update - Here's the tl;dr version of the problem - the following snippet doesn't work when run as an independent script unless I comment out the SetOutPath call. WHY? It does not matter whether the output directory has any files in it or not(it doesn't), or whether I call it immediately before or several lines before.

showinstdetails show
 OutFile test.exe
section
 setoutpath "D:\back"
 ExecWait "msiexec /i MyInstaller.msi /qr" $0
 MessageBox MB_OK $0
sectionend

Solution

  • Found out what was wrong, with partial help from Nick and Anders above. In my other script which worked, I was calling SetOutPath after invoking the MSI.

    Changing the sequence worked.

    So lesson learned - relative paths get screwed up after calling SetOutPath , so in my original example, the path to the msi would be resolved against what was set in 'SetOutPath instead of using the current directory, where the installer is located.

    Thanks guys!