Waiting for msiexec.exe to Finish

Waiting for msiexec.exe to Finish

  • Comments 9

Since Windows Installer 1.0 was first released, msiexec.exe has always run in the Windows subsystem. That means that when it is executed from the console or by a batch script control returns to the console or script immediately. If you depend upon the %ERRORLEVEL% variable being set accordingly it won't be.

In this scenario I like to use start /wait from the command line or a batch script. This will create the process and wait for it to exit, and the return code from the process is passed through and returned from the start command such that %ERRORLEVEL% is set accordingly. Just type start /wait before the command line you'd normally pass to msiexec.exe like in the following example:

start /wait msiexec.exe /i netfx.msi /l*v netfx.log

A batch script would be blocked, then, until msiexec.exe finishes. Programmatically this is no different than invoking msiexec.exe with CreateProcess and waiting for the process handle to be signaled with WaitForSingleObject with no timeout.

Leave a Comment
  • Please add 2 and 8 and type the answer here:
  • Post
  • This is great!

    Really useful for running automated tests on an installation kit.

    Before, I had to poll a 'key' file to tell that the install had completed. Nightmare!

  • How to extract files from a patch by patching an administrative installation and the hard way using OLE structured storage APIs.
  • Cheers mate - just what we needed for a sticky uninstall problem.
  • Finally I solved it ! Thanks to you !!!!!!!!
  • The upcoming Visual Studio 2005 Service Pack 1 can take a while to install and can require a lot of disk

  • This advice is out of date now, no longer works.

  • Gerry,

    I just used this.  It still works.

  • Thanks! Really great for automation!

  • Cool! this helped me.

Page 1 of 1 (9 items)