title: Run batch file or command in wix installer when IT disables Command Prompt
body: <p>I've created an installer using wix toolset. Since the main application is a web application, I need to install the web certificate and edit the host file. To do so, I wrote a batch file that will edit the host file and added a Wix property to add the WebCert.</p>
  
  <p>The batch file is as so:</p>
  
  <pre><code>FIND /C /I "site.site.com" %WINDIR%\system32\drivers\etc\hosts
  IF %ERRORLEVEL% NEQ 0  (
      ECHO. &gt;&gt;%WINDIR%\System32\drivers\etc\hosts
      ECHO ^127.0.0.1 site.site.com&gt;&gt;%WINDIR%\System32\drivers\etc\hosts
      ECHO. &gt;&gt;%WINDIR%\System32\drivers\etc\hosts
  </code></pre>
  
  <p>And in the Component.wxs:</p>
  
  <pre><code>&lt;iis:Certificate Id="rootWebCert"
                   Name="site"
                   Request="no"
                   BinaryKey="site.pfx"
                   StoreName="root"
                   PFXPassword="PASSWORD"
                   StoreLocation="localMachine"/&gt;
  </code></pre>
  
  <p>Now this runs fine on computers with more freedom, but there are some computers on our domain that are locked down and one of the features they lock is Command Prompt. Is there an alternative way to edit the host file or install the web cert? I've also done this in PowerShell, but that would require to install PowerShell on the limited computers also.</p>
  
  <p>EDIT:</p>
  
  <p>I was given access to their machines and confirmed that after accepting the EULA and Install Location, the 'Install' button did prompt for elevated permissions and they were able to authenticate through and the installer DID NOT report any errors but the script DID NOT go through. What I found DID work was opening command prompt as admin, and running <code>msiexec /i installer.msi</code></p>
  
  <p>I also added the following lines in the wxs:</p>
  
  <pre><code>&lt;Condition Message="Installation requires Administrator privileges"&gt;
    &lt;![CDATA[Privileged]]&gt;
  &lt;/Condition&gt;
  </code></pre>
  
  <p>This part was already there, just forgot to put into the original post:</p>
  
  <pre><code>&lt;InstallExecuteSequence&gt;
    &lt;Custom Action="CustomBatchFile" After="InstallFiles"&gt;&lt;![CDATA[NOT Installed]]&gt;&lt;/Custom&gt;
  &lt;/InstallExecuteSequence&gt;
  &lt;CustomAction Id="CustomBatchFile"
                ExeCommand="&amp;quot;[SHORTCUTDIR]CustomBatch.bat&amp;quot; &amp;quot;[INSTALLFOLDER]&amp;quot;"
                Directory="SHORTCUTDIR" 
                Execute="deferred" 
                Return="asyncNoWait"/&gt;
  </code></pre>