title: "net use" command in a Windows Service
body: <p>We're using the following command line from within a Windows Service developed with C# .Net Framework 1.1:</p>
  
  <pre><code>net use z: \\myComputer\c$
  </code></pre>
  
  <p>The service is running under a domain account that is a local administrator on "myComputer". After debugging the code we can see that it does not return any errors but the "z:" drive is never mapped. We've tried the exact same code from a console application and it works properly. What is it that we need to add to the Service to make this work?</p>
  
  <p>The code we're using is included below.</p>
  
  <p>Regards,<br>
  Sergio</p>
  
  <pre><code>startInfo.FileName = "net";  
  startInfo.Arguments = string.Format(@"use {0}: \\{1}\{2}", driveLetter,
                                      computerName, folder).Trim();  
  startInfo.UseShellExecute = false;  
  startInfo.RedirectStandardError = true;
  
  proc.EnableRaisingEvents = false;  
  proc.StartInfo = startInfo;
  
  proc.Start();
  
  // If there is an error during the mapping of the drive, it will be read
  // from the StandardError property which is a StreamReader object and
  // be fed into the error output parameter.  
  using(StreamReader errorReader = proc.StandardError)  
  {  
           string standardError = string.Empty;  
      while((standardError = errorReader.ReadLine()) != null)  
      {  
          error += standardError + " ";  
      }  
  }  
  proc.WaitForExit();  
  </code></pre>