NSIS Installers and ExecWait

This week I’ve been developing an installer using NSIS to facilitate software deployment. Part of the installer requires me to install another application (MySQL in this case) and then run a configuration script against the newly installed software. Here’s the general procedure:

  1. Begin installer (for my software)
  2. Unpack MySQL installer (delivered as an MSI and packed into my installer)
  3. Silently install MySQL. I do this running the installer from the command line like this:
    msiexec /quiet /i mysql.msi
  4. Run the configuration script to install the Windows Service and create an ini file
  5. Continue on with other installer tasks.

Notice that before I move on to step 4 I have to be sure that the installation completes. If installation isn’t complete then the configuration step will fail. I had initially hoped that the ExecWait feature would provide me what I needed, but it didn’t work out that easy.

It turns out that msiexec exits after successfully starting the installer and so step 4 begins before the installation in step 3 completes. A little Google searching brought me to this promising article about using start /wait. However, putting “start /wait” in the command for ExecWait didn’t work.


Eventually I got the idea that I would add another step. Here’s how it works now:

  1. Begin Installer
  2. Unpack MySQL installer
  3. Build a .bat file with the installer command that I want
    start /wait msiexec /quiet /i mysql.msi
  4. Silently install MySQL by calling the .bat file: ExecWait installmysql.bat
  5. Run the configuration script to install the Windows Service and create an ini file
  6. Continue on with other installer tasks.

Here’s some sample code you can use if you want to accomplish the same thing

  ; Create batch file 
  FileOpen $0 "calcwait.bat" "w"
  FileWrite $0 "start /wait $SYSDIR\calc.exe"
  FileClose $0

  ; View file
  ExecWait '"calcwait.bat"'
Twitter Digg Delicious Stumbleupon Technorati Facebook Email

About Daniel Watrous

I'm a Software & Electrical Engineer and online entrepreneur.

2 Responses to “NSIS Installers and ExecWait”

  1. Fatal error: Uncaught Error: Call to undefined function ereg() in /home/dwatrous/webapps/software_danielwatrous_com/wp-content/themes/headlines/includes/theme-comments.php:66 Stack trace: #0 /home/dwatrous/webapps/software_danielwatrous_com/wp-content/themes/headlines/includes/theme-comments.php(22): the_commenter_link() #1 /home/dwatrous/webapps/software_danielwatrous_com/wp-includes/class-walker-comment.php(180): custom_comment(Object(WP_Comment), Array, 1) #2 /home/dwatrous/webapps/software_danielwatrous_com/wp-includes/class-wp-walker.php(146): Walker_Comment->start_el('', Object(WP_Comment), 1, Array) #3 /home/dwatrous/webapps/software_danielwatrous_com/wp-includes/class-walker-comment.php(140): Walker->display_element(Object(WP_Comment), Array, '5', 0, Array, '') #4 /home/dwatrous/webapps/software_danielwatrous_com/wp-includes/class-wp-walker.php(371): Walker_Comment->display_element(Object(WP_Comment), Array, '5', 0, Array, '') #5 /home/dwatrous/webapps/software_danielwatrous_com/wp-includes/comment-template.php(20 in /home/dwatrous/webapps/software_danielwatrous_com/wp-content/themes/headlines/includes/theme-comments.php on line 66