title: How to run a batch file before process starts?
body: <p>I am trying to start a program with the following code: </p>
  
  <pre><code>private static void RunPlmxml(string plmxmlPath, string arguments) 
  {
      Process process = new Process();
      process.StartInfo.Arguments = arguments;
      process.StartInfo.FileName = plmxmlPath;
      process.StartInfo.EnvironmentVariables["TC_ROOT"] = teamcenterRootPath;
      process.Start();
      process.WaitForExit();
  
      // Other code
  
      return;
  }
  </code></pre>
  
  <p>This works fine but, i am missing a lot of environment variables. These variables are set in <code>%TC_DATA%\tc_profilevars.bat</code>. I want to run this bat file before i start this process so that the program has all the variables it needs. So what i want to do is something like this:</p>
  
  <pre><code>private static void RunPlmxml(string plmxmlPath, string arguments) 
  {
      string teamcenterRootPath = Environment.GetEnvironmentVariable("TC_ROOT");
      string teamcenterDataPath = Environment.GetEnvironmentVariable("TC_DATA");
  
  
      Process process = new Process();
      process.StartInfo.Arguments = arguments;
      process.StartInfo.FileName = plmxmlPath;
      process.StartInfo.EnvironmentVariables["TC_ROOT"] = teamcenterRootPath;
      process.StartInfo.EnvironmentVariables["TC_DATA"] = teamcenterDataPath;
      process.StartInfo.BeforeStart("%TC_DATA%\tc_profilevars.bat")
  
      process.Start();
      process.WaitForExit();
  
      // Other code
  
      return;
  }
  </code></pre>
  
  <p>I do not want to create another bat file that starts this process since i do not want to ship my product with a bat file included. </p>