title: Suppressing The Command Window Opening When Using Start-Process
body: <p>I'm trying to find a way to get PowerShell not to spawn a command window when running an executable using <code>Start-Process</code>.</p>
  
  <p>If I call the executable directly within the script (e.g. <code>.\program.exe</code>) then the program runs (with its arguments) and the output is returned to the PowerShell window.</p>
  
  <p>If I use <code>Start-Process</code> the program spawns a command window where the program runs and returns it's output.</p>
  
  <p>If I try and use the <code>-NoNewWindow</code> switch of <code>Start-Process</code> the script then errors out saying it can't find the exe file.</p>
  
  <p>I would prefer to use <code>Start-Process</code> to have access to the <code>-Wait</code> switch, as the programs and configurations the script makes can take some time individually to finish, and I don't want later commands starting up.</p>
  
  <p>This code runs the executable in a separate command window:</p>
  
  <pre><code>Start-Process DeploymentServer.UI.CommandLine.exe -ArgumentList "download --autoDownloadOn --autoDownloadStartTime $StartTime --autoDownloadEndTime $EndTime" -Wait
  </code></pre>
  
  <p>This code runs the exe within the PowerShell console:</p>
  
  <pre><code>.\DeploymentServer.UI.CommandLine.exe download --autoDownloadOn --autoDownloadStartTime $StartTime --autoDownloadEndTime $EndTime
  </code></pre>
  
  <p>If I add the -NoNewWindow to the Start-Process code</p>
  
  <pre><code>Start-Process DeploymentServer.UI.CommandLine.exe -ArgumentList "download --autoDownloadOn --autoDownloadStartTime $StartTime --autoDownloadEndTime $EndTime" -Wait -NoNewWindow
  </code></pre>
  
  <p>I get the following error:</p>
  
  <pre>Start-Process : This command cannot be executed due to the error: The system
  cannot find the file specifie
  At C:\Temp\SOLUS3Installv1.3.ps1:398 char:22
  +         Start-Process &lt;&lt;&lt;&lt;  DeploymentServer.UI.CommandLine.exe -ArgumentList "download --autoDownloadStartTime $StartTime --autoDownloadEndTime $EndTime" -Wait -NoNewWindow
      + CategoryInfo          : InvalidOperation: (:) [Start-Process], InvalidOperationException
      + FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.Commands.StartProcessCommand</pre>