title: UNC path can be mapped from command line but not from .NET Console application
body: <p>How can I make the .NET code map the Z: drive to the UNC path for account SVNdatamgmt?</p>
  
  <p>I'm trying to map a local drive to a network UNC path within a .NET console application.  The code seems to work from the command line for both the service account (#2 and #3) and with my credentials (#4).  But when running from the Console application using .NET source code, the service account doesn't work (#5), but my credentials do work (#6).</p>
  
  <p>Last night, I noticed that I got an error (#1).  After waiting 30 minutes, it worked.  So you can ignore #1.  I thought I'd mention it, in case it gives a clue as to what is happening.  </p>
  
  <p>The console application is running as an administrator on a Windows Server 2008 box.  Both SVCdatamgmt and macgyver are administrators on this machine.  The commands are also being run on this same machine.</p>
  
  <p>========================================================================<BR />
  <strong><em>1.) This didn’t work last night:</em></strong></p>
  
  <p>C:><code>net use z: \\uwhc-sas2\SASHIMC /USER:SVCdatamgmt thepassword</code></p>
  
  <pre><code>System error 1909 has occurred.
  The referenced account is currently locked out and may not be logged on to.
  </code></pre>
  
  <p>========================================================================<BR />
  <strong><em>2.) Waited 30 minutes and then this worked (without domain):</em></strong></p>
  
  <p>C:><code>net use z: \\uwhc-sas2\SASHIMC /USER:SVCdatamgmt thepassword</code></p>
  
  <pre><code>The command completed successfully.
  </code></pre>
  
  <p>========================================================================<BR />
  <strong><em>3.) This also works (with domain):</em></strong></p>
  
  <p>C:><code>net use z: \\uwhc-sas2\SASHIMC /USER:UWHIS\SVCdatamgmt thepassword</code></p>
  
  <pre><code>The command completed successfully.
  </code></pre>
  
  <p>========================================================================<BR />
  <strong><em>4.) This also works with my credentials:</em></strong></p>
  
  <p>C:><code>net use z: \\uwhc-sas2\SASHIMC /USER:macgyver thepassword</code></p>
  
  <pre><code>The command completed successfully.
  </code></pre>
  
  <p>========================================================================<BR />
  <strong><em>5.) .NET code that maps drive.  SVCdatamgmt credentials do not work.</em></strong></p>
  
  <pre><code>public static void MapNetworkDriveToUNC()
  {
      var command = @"net use " + mapDrive + " " + uncPath + " " + uncUser + " " + uncPass;
      ExecuteCommand(command, 10000);
  }
  
  public static void UnmapNetworkDriveToUNC()
  {
      var command = "net use " + mapDrive + " /delete";
      ExecuteCommand(command, 5000);
  }
  </code></pre>
  
  <p>========================================================================<BR />
  <strong><em>6.) .NET code that maps drive.  My credentials work (macgyver)</em></strong></p>
  
  <p>-- same code as #5 --</p>
  
  <p>========================================================================<BR />
  <strong>FYI: before running each command above, I have to disconnect (unmap) the drive using this code...</strong></p>
  
  <pre><code>C:\&gt;net use z: /delete
  
  z: was deleted successfully.
  </code></pre>