title: How Might I Convert This C# Code In To Batch File Code?
body: <p>I have read that Win32 will not allow remote invocation of a process that is interactive and I suspect a Console Application is considered to be interactive by Windows and so instead, if I could convert the following code in to a batch file then I am hoping I can remotely run the batch file on the server computer from a client. Feel free to correct this logic if I'm wrong.</p>
  
  <p>The code is:</p>
  
  <pre><code>namespace PRIMEWebFlyControl
  {
    class Program
    {
  
      // name of the process we will retrieve a handle to
      private const string PROCESS_NAME = "PRIMEPipeLine";
      private static Process ProgramHandle;
      private static string command;
  
      static void Main(string[] args)
      {
          //Console.WriteLine("This program has been launched remotely!");
          TextReader tr = new StreamReader("C:\\inetpub\\wwwroot\\PRIMEWeb\\Executables\\FlyCommand.txt");
          command = tr.ReadLine();
          tr.Close();
  
          ExecuteCommand();
      }
  
      [DllImport("user32.dll")]
      static extern bool SetForegroundWindow(IntPtr handle);
  
      private static void ExecuteCommand() {
          if (AssignProcessHandle()) {
              IntPtr p = ProgramHandle.MainWindowHandle;
              SetForegroundWindow(p);
              SendKeys.SendWait(command + "~"); // "~" is equivalent to pressing Enter
          }
      }
  
  
  
      private static bool AssignProcessHandle()
      {
          // ask the system for all processes that match the name we are looking for
          Process[] matchingProcesses = Process.GetProcessesByName(PROCESS_NAME);
          // if none are returned then we haven't found the program so return false;
          if (matchingProcesses.Length == 0) return false;
          // else, set our reference to the running program
          ProgramHandle = matchingProcesses[0];
  
          // return true to indicate we have assigned the ref sucessfully
          return true;
      }
  
  }
  }
  </code></pre>
  
  <p>As you will notice the code contains method calls of Windows library methods like SetForegroundWindow() and as I am unfamiliar with batch files, I wondered how the same thing might be achieved.</p>
  
  <p>Many thanks</p>