title: How to execute a bat file on remote server?
body: <p>I have two physical machine. The first machine want to execute a bat file on the second machine. I create a share location on the second server and tried to run it from the first machine and it does not work. The bat file can run on the local machine properly.</p>
  
  <p>This is an example of code inside the bat file. It is just a bat to create file.</p>
  
  <pre><code>echo. 2&gt;EmptyFile.txt
  </code></pre>
  
  <p>This is the code that I use to execute bat file.</p>
  
  <pre><code>private static void ExecuteBatFile()
  {
      System.Diagnostics.Process proc = new System.Diagnostics.Process();
      System.Security.SecureString ssPassword = new System.Security.SecureString();
  
      proc.StartInfo.UseShellExecute = false;
      proc.StartInfo.FileName = @"\\my_remote_server\my_bat.bat";
      proc.StartInfo.Domain = "my_domain";
      proc.StartInfo.UserName = "my_username";
  
      Console.Write("Enter your password: ");
      string password = Console.ReadLine();
  
      for (int x = 0; x &lt; password.Length; x++)
      {
          ssPassword.AppendChar(password[x]);
      }
  
      proc.StartInfo.Password = ssPassword;
      proc.Start();
  }
  </code></pre>
  
  <p>I want to know how can I run bat file on remote server?</p>