title: Powershell script gets stuck, doesn't exit when called from batch file
body: <p>I have a PowerShell script that connects to a web site, and parses its returned data (It's about importing a previously uploaded SQL file into the web site's data base). The PowerShell script uses <code>wget</code>, something I may replace by a native function later.</p>
  
  <p>The import process is embedded in a script that is executed by a 3rd party program called <a href="http://www.scriptftp.com" rel="noreferrer">scriptFTP</a>.</p>
  
  <p>The script runs fine when I call it from a single .bat file like so:</p>
  
  <pre><code>powershell  "&amp; "C:\data\etc\run_import_script.ps1"
  exit %ERRORLEVEL%
  </code></pre>
  
  <p>However, when I call this .bat file from within the greater ScriptFTP context, the following happens:</p>
  
  <ul>
  <li>The PowerShell script <strong>is executed</strong>. I confirmed this my sending myself an E-Mail each time the remote import script got called.</li>
  <li><strong>PowerShell doesn't seem to exit, and script execution gets stuck</strong>. I can still cancel the whole thing using Ctrl+C but the following commands never get executed.</li>
  </ul>
  
  <p>When I change the batch file to the following:</p>
  
  <pre><code>start powershell  "&amp; "C:\data\etc\run_import_script.ps1"
  exit %ERRORLEVEL%
  </code></pre>
  
  <p>it <strong>works</strong>, running the PowerShell script in a new console, but I can't grab the error level that PowerShell returns. </p>
  
  <p>I have tried calling PowerShell from ScriptFTP directly, bypassing the batch file, but with the same result: It just gets stuck.</p>
  
  <p>Any output I have the PowerShell script do using <code>Write-Output</code> or <code>Write-Host</code> is not displayed.</p>
  
  <p>All programs run under the same user, me. </p>
  
  <p>Does anybody have any ideas what to do?</p>