title: PowerShell: Start a process with unquoted arguments
body: <p>My PowerShell script should start an external executable with specified parameters. I have two strings: The file name, and the arguments. This is what process starting APIs usually want from me. PowerShell however fails at it.</p>
  
  <p>I need to keep the executable and arguments in a separate strings because these are configured elsewhere in my script. This question is just about using these strings to start the process. Also, my script needs to put a common base path in front of the executable.</p>
  
  <p>This is the code:</p>
  
  <pre><code>$execFile = "SomeSetup.exe"
  $params = "/norestart /verysilent"
  &amp; "$basePath\$execFile" $params | Out-Host
  # Pipe to the console to wait for it to finish
  </code></pre>
  
  <p>This is the actual result (does not work with this program):</p>
  
  <ul>
  <li>Process file name: "C:\My\Base path\SomeSetup.exe"</li>
  <li>Process command line: <strong>"/norestart /verysilent"</strong></li>
  </ul>
  
  <p>This is what I'd expect to have (this would work):</p>
  
  <ul>
  <li>Process file name: "C:\My\Base path\SomeSetup.exe"</li>
  <li>Process command line: <strong>/norestart /verysilent</strong></li>
  </ul>
  
  <p>The problem is that the setup recognises the extra quotes and interprets the two arguments as one - and doesn't understand it.</p>
  
  <p>I've seen <code>Start-Process</code> but it seems to require each parameter in a string[] which I don't have. Splitting these arguments seems like a complicated shell task, not something I'd do (reliably).</p>
  
  <p>What could I do now? Should I use something like</p>
  
  <pre><code>&amp; cmd /c "$execFile $params"
  </code></pre>
  
  <p>But what if $execFile contains spaces which can well happen and usually causes much more headache before you find it.</p>