title: PsExec and invalid handles
body: <p>I am trying to use a windows batch script that uses PsExec to execute commands on a remote machine. Periodically it has "invalid handle" and the script then fails. </p>
  
  <p>The script has not altered or indeed either machine.</p>
  
  <p>Does anybody know why this happens as sometimes the scripts runs without a hitch.</p>
  
  <p>Alternatively does anybody know how to run a script on a machine as the local user for that machine with a more reliable technology.</p>
  
  <p><strong>PS</strong> Sometimes the first <code>PsExec</code> works and the others fail.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>The script is just on line (apart from setting the appropriate variables)</p>
  
  <pre><code> PsExec %HOSTNAME% -I -u %USERNAME% -p %PASSWORD% CMD /C RMDIR /S /Q e:\SomeDir
  </code></pre>
  
  <p>This sometimes works but sometimes fails with "invalid handle"</p>