Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to make an install script. I want to install an .msi file, Python, and then install other things after Python is installed. I already see how to do a command-line install. However, msiexec returns right away, even when the install is still running. How would I detect the completion of an msi install from a batch script?

share|improve this question
Do you have any control over the msi file at all? Can you break it down modify it and repackage? – John Gardeniers Oct 12 '10 at 3:09
no it's not my msi file – Claudiu Oct 13 '10 at 16:05
up vote 6 down vote accepted

Don't know how Python handles passing commands off to Windows/DOS, but using a plain batch file and the start /wait command the batch file stops and waits until the MSI is done before moving on to the next step.

For example, to install a main app, followed by a patch only when it's finished, and then a final program once that's finished, drop these lines into a .cmd file:

start /wait msiexec /i O12Conv.msi /qb
start /wait msiexec /p O12Convsp1-en-us.msp /qb
start /wait msiexec /i mpsetupedp.msi
share|improve this answer
+1, When using start watch for the title "bug". Paths containing a space will be interpreted as the title portion of the command line arguments. Use something like: start "" /wait msiexec /i some.msi /qb just to ensure title is set. – jscott Oct 19 '10 at 11:35
@jscott Hadn't heard of that problem before, but we've always stored our installers on a specific installer share, and all folder names on that share are strictly 8.3 with no spaces, as there've been so many odd quirks with badly written installers in the past that it ended up easier to keep everything simple. – GAThrawn Oct 19 '10 at 12:21

It's tricky, and not reliable, but there are ways to monitor for the existence of a specific process in the process list. You write your loop to NOOP while waiting for that process to no longer be there, and then you do your next steps. There are a couple of ways of handling this.

The SysInternals tool pslist will show processes, though parsing the output can be tricky. PowerShell can access the .NET APIs to do process monitoring through the get-process cmdlet.

These methods merely monitor for the existence of a process, they can't check for the exit codes and therefore can't know whether or not a process exited normally or in an error state. For that, you'll have to process any MSI logs you specified be generated, or possibly dig in the Windows Even Log for error events.

share|improve this answer

A successful install will return any of the 3 codes: 0,1641,3010 depending on the reboot option. Please try to modify your script such that it will in return throw the codes.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.