title: Windows access denied error message on using net use
body: <p>I am having following issue when I try to use <code>net use</code> using a batch file which is configured in <em>Hudson</em>.</p>
  
  <p>I added <code>test</code> user as administrator in remote Windows Server 2012 and also set the password.</p>
  
  <p>My batch script:</p>
  
  <pre><code>net use p: /delete  
  net use p: "\\cazrt\C$" /USER:test /PERSISTENT:NO xxxxx
  set "source=%~1"
  set "target=p:/%~2"
  
  echo "%source%" "%target%"
  
  echo F|xcopy /S /I /Q /Y "%source%" "%target%"
  </code></pre>
  
  <p>Output on execution:</p>
  
  <pre><code>[exec] C:\HudsonProjects\NGA&gt;net use p: /delete   
  [exec] 
  [exec] C:\HudsonProjects\apps&gt;net use p: "\\cazrt\C$" /USER:test /PERSISTENT:NO xxxxx 
  [exec] System error 5 has occurred.
  [exec] 
  [exec] Access is denied.
  </code></pre>
  
  <p>If I try to use <code>net use</code> without <code>PERSISTENT</code>, I get the same access denied error and the network connection could not be found.</p>
  
  <p>Output on execution:</p>
  
  <pre><code>[exec] C:\HudsonProjects\NGA&gt;net use p: /delete   
  [exec] 
  [exec] C:\HudsonProjects\apps&gt;net use p: "\\cazrt\C$" /USER:test xxxxx 
  [exec] The network connection could not be found.
  [exec] More help is available by typing NET HELPMSG 2250.
  [exec] 
  [exec] 
  [exec] 
  [exec] C:\HudsonProjects\apps&gt;set "source=D:/target/DROP" 
  [exec] 
  [exec] C:\HudsonProjects\apps&gt;set "target=p:/C:/temp" 
  [exec] 
  [exec] C:\HudsonProjeSystem error 5 has occurred.
  [exec] 
  [exec] Access is denied.
  </code></pre>
  
  <p>If I type <code>net use</code> from local windows machine, it is showing:</p>
  
  <pre><code>\\cazrt\c$ command executed successful.
  </code></pre>