{"id":2663,"date":"2005-11-15T22:12:00","date_gmt":"2005-11-15T22:12:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/heaths\/2005\/11\/15\/waiting-for-msiexec-exe-to-finish\/"},"modified":"2005-11-15T22:12:00","modified_gmt":"2005-11-15T22:12:00","slug":"waiting-for-msiexec-exe-to-finish","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/setup\/waiting-for-msiexec-exe-to-finish\/","title":{"rendered":"Waiting for msiexec.exe to Finish"},"content":{"rendered":"<p>Since Windows Installer 1.0 was first <a href=\"http:\/\/msdn.microsoft.com\/library\/en-us\/msi\/setup\/released_versions_of_windows_installer.asp\">released<\/a>, <em>msiexec.exe<\/em> 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 <code>%ERRORLEVEL%<\/code> variable being set accordingly it won&#8217;t be.<\/p>\n<p>In this scenario I like to use <code>start \/wait<\/code> 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 <code>%ERRORLEVEL%<\/code> is set accordingly. Just type <code>start \/wait<\/code> before the command line you&#8217;d normally pass to <em>msiexec.exe<\/em> like in the following example:<\/p>\n<pre>start \/wait msiexec.exe \/i netfx.msi \/l*v netfx.log<\/pre>\n<p>A batch script would be blocked, then, until <em>msiexec.exe<\/em> finishes. Programmatically this is no different than invoking <em>msiexec.exe<\/em> with <a href=\"http:\/\/msdn.microsoft.com\/library\/en-us\/dllproc\/base\/createprocess.asp\"><code>CreateProcess<\/code><\/a> and waiting for the process handle to be signaled with <a href=\"http:\/\/msdn.microsoft.com\/library\/en-us\/dllproc\/base\/waitforsingleobject.asp\"><code>WaitForSingleObject<\/code><\/a> with no timeout.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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&#8217;t be. In this scenario I [&hellip;]<\/p>\n","protected":false},"author":389,"featured_media":3843,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[20],"class_list":["post-2663","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorized","tag-installation"],"acf":[],"blog_post_summary":"<p>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&#8217;t be. In this scenario I [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/setup\/wp-json\/wp\/v2\/posts\/2663","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/setup\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/setup\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/setup\/wp-json\/wp\/v2\/users\/389"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/setup\/wp-json\/wp\/v2\/comments?post=2663"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/setup\/wp-json\/wp\/v2\/posts\/2663\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/setup\/wp-json\/wp\/v2\/media\/3843"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/setup\/wp-json\/wp\/v2\/media?parent=2663"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/setup\/wp-json\/wp\/v2\/categories?post=2663"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/setup\/wp-json\/wp\/v2\/tags?post=2663"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}