title: Powershell Call MSI with Arguments
body: <p>I'm working on a powershell script to install Autodesk products and I am having some trouble. </p>
  
  <p>I've tried this many different ways and keep running into errors.</p>
  
  <p>Using double quotes</p>
  
  <pre><code>(Start-Process "msiexec.exe" -ArgumentList ""/i $dirFiles\ABDS2017\Img\x64\RVT\RVT.msi INSTALLDIR="C:\Program Files\Autodesk\" ADSK_SETUP_EXE=1 /qb!"" -NoNewWindow -Wait -PassThru).ExitCode
  </code></pre>
  
  <p>Error Cannot validate argument on parameter 'ArgumentList' Argument is null or empty.</p>
  
  <p>Using a variable to define InstallDir</p>
  
  <pre><code>$RevitInstallDir = "C:\Program Files\Autodesk\"
      (Start-Process "msiexec.exe" -ArgumentList "/i $dirFiles\ABDS2017\Img\x64\RVT\RVT.msi INSTALLDIR=$RevitInstallDir ADSK_SETUP_EXE=1 /qb!" -NoNewWindow -Wait -PassThru).ExitCode
  </code></pre>
  
  <p>Doing this I get the msiexec /option Required Parameter error.</p>
  
  <p>Tried this also, Single Quotes with Quotes on Path</p>
  
  <pre><code>(Start-Process "msiexec.exe" -ArgumentList "/i $dirFiles\ABDS2017\Img\x64\RVT\RVT.msi INSTALLDIR="C:\Program Files\Autodesk\" ADSK_SETUP_EXE=1 /qb!" -NoNewWindow -Wait -PassThru).ExitCode
  </code></pre>
  
  <p>I receive A positional parameter cannot be found that accepts argument C:\Program</p>
  
  <p>Using single quotes on InstallDir</p>
  
  <pre><code>(Start-Process "msiexec.exe" -ArgumentList "/i $dirFiles\ABDS2017\Img\x64\RVT\RVT.msi INSTALLDIR='C:\Program Files\Autodesk\' ADSK_SETUP_EXE=1 /qb!" -NoNewWindow -Wait -PassThru).ExitCode
  </code></pre>
  
  <p>Doing this I get the msiexec /option Required Parameter error.</p>
  
  <p>Using single quotes on the outside</p>
  
  <pre><code>(Start-Process "msiexec.exe" -ArgumentList '/i $dirFiles\ABDS2017\Img\x64\RVT\RVT.msi INSTALLDIR="C:\Program Files\Autodesk\" ADSK_SETUP_EXE=1 /qb!' -NoNewWindow -Wait -PassThru).ExitCode
  </code></pre>
  
  <p>If I do this, it prevents the $dirFiles variable from working. </p>
  
  <p>The reason I'm using Start-Process is because I have many installers one after the other and I want one installer to wait till the one before it finishes. Any help would be appreciated! Thanks</p>
  
  <p>EDIT: Nevermind, I figured it out. </p>
  
  <pre><code>(Start-Process "msiexec.exe" -ArgumentList "/i $dirFiles\ABDS2017\Img\x64\RVT\RVT.msi INSTALLDIR=""C:\Program Files\Autodesk\"" ADSK_SETUP_EXE=1 /qb!" -NoNewWindow -Wait -PassThru).ExitCode
  </code></pre>
  
  <p>Double Quotes around the Install Dir</p>
  
  <p>Got the idea from here. <a href="https://blogs.technet.microsoft.com/heyscriptingguy/2015/06/20/weekend-scripter-understanding-quotation-marks-in-powershell/" rel="nofollow noreferrer">https://blogs.technet.microsoft.com/heyscriptingguy/2015/06/20/weekend-scripter-understanding-quotation-marks-in-powershell/</a></p>
  
  <p>Thanks</p>