Wednesday, August 1, 2012

Using NSIS to launch msp installation.

Today, I got a task to deliver a msp file (Windows Installer Patch) to the user machine. To install *.msp files, we usually have to issue following command line:

msiexec /p “<msp file name with path>” REINSTALLMODE=oums REINSTALL=ALL /qr

For more details, see this article

And it seems odd to ask user to issue that log, horrible command line. So either, either I have to provide my user with a .bat/.cmd file containing above command line, or a self extractive archive containing the Patch and its command line. 

The best convenient method I found for my user is some self extractive archive and I quickly choose NSIS ((Nullsoft Scriptable Install System).

Plan was simple:

  1. Deliver *.msp file to a Temp folder
  2. Launch Patch installation with above command line and log the installation
  3. NSIS installer should not show the details of installation.
  4. Remove *.msp File but leave the Log file thereat the End of Patch installation
  5. Auto-Close the NSIS Window.

So making long story short, here is that NSIS script. Smile

NSIS Code to launch msp installation
  1. !define PRODUCT_NAME "Patch for build 225"
  2. !define PRODUCT_VERSION "8.11.9.357"
  3. !define PRODUCT_PUBLISHER "My Company, Inc."
  4. !define PRODUCT_WEB_SITE "http://www.google.com"
  5. Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
  6. OutFile "Patch for build 225.exe"
  7. InstallDir "$TEMP"
  8. Icon "Bentley.ico"
  9. SilentInstall normal
  10. ;//This will make installer not to show the details
  11. ShowInstDetails nevershow
  12. Section "MainSection" SEC01
  13.    ;//This will close the NSIS Installer Window at end.
  14.    SetAutoClose true
  15.    SetOutPath "$TEMP\PATCH_225_357"
  16.    SetOverwrite ifnewer
  17.     File "PATCH_225_357.msp"
  18. SectionEnd
  19. Section -Post 
  20.     ExecWait '"msiexec.exe" /p "$TEMP\PATCH_225_357\PATCH_225_357.msp" REINSTALLMODE=oums REINSTALL=ALL /qr /l*v "$TEMP\PATCH_225_357\PATCH_225_357.log"'
  21.     Delete /REBOOTOK "$TEMP\PATCH_225_357\PATCH_225_357.msp"
  22. SectionEnd

 

No comments: