title: Copy file to network path using Windows Service using cmd file
body: <p>I am trying to copy the xml file from the local folder to shared path using C# code in my Windows Service.</p>
  
  <p>It is calling the CMD file and returns <strong>Access Denied</strong>. But same is works if I try copying to local.</p>
  
  <pre><code>private void CopyFile(string path)
      {
          try
          {
  
              Process process = new Process();
              ProcessStartInfo startInfo = new ProcessStartInfo();                
              startInfo.UseShellExecute = false;
              startInfo.FileName = Path.Combine(Environment.CurrentDirectory, "Batch", "Run.cmd");
              startInfo.Arguments = "/c " + path;                               
              startInfo.RedirectStandardError = true;
              startInfo.RedirectStandardOutput = true;
  
              process = Process.Start(startInfo);
              process.WaitForExit();
              string output = process.StandardOutput.ReadToEnd();
              string error = process.StandardError.ReadToEnd(); // ACCESS DENIED
              int  exitCode = process.ExitCode; // 1
  
  
              process.Close();
  
          }
          catch (Exception ex)
          {
              string x = ex.Message;
          }
      }
  </code></pre>
  
  <p><strong>Run.cmd</strong></p>
  
  <pre><code>@set sourcePath=%1
  
  copy /y %sourcePath%\MyTest.xml \\networksharedPath\XML\MyTest.xml
  </code></pre>
  
  <p>The Windows service's project installer has configured to use <strong>LocalSystem</strong> Account.</p>
  
  <p>How to make the service to copy the file from local folder to shared machine? Any issues with the C# code or Windows Process Installer configuration? </p>
  
  <p><strong>Note</strong>: Manually clicking the cmd file copies to the shared folder. If I modify as Network Service and run I get same error <code>Access is Denied</code>. Tried configuring steps given in <a href="https://stackoverflow.com/a/11983513/1559213">https://stackoverflow.com/a/11983513/1559213</a> But no luck..</p>