title: How to hide cmd window ,close it and wait for executing automatically
body: <p>I have problem with command line window after executing bat file. I want to run bat file, without cmd window shown, close it and after all this open my PDF file which is generated using my program and bat file. My code:</p>
  
  <pre><code> Process p1 = new Process();
              p1.StartInfo.FileName = @"C:\dir\batch.bat";
              p1.StartInfo.Arguments = @"C: \dir\final.tex";
              p1.StartInfo.UseShellExecute = false;
              p1.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
  
  
              p1.Start();
              p1.WaitForExit(15*1000);
              p1.Close();
  
              Process.Start(@"C:\dir\final.pdf");
  </code></pre>
  
  <p>So what happens in my case: Everything runs as it should do, but my PDF is show before my bat file is doing the job. How to make my <code>Process.Start(pdf)</code> wait, till my bat file will finish the job? When using <code>p1.WaitForExit()</code>, I need manually exit the cmd window, I don't want to do this. Any ideas?</p>
  
  <p>Thanks.</p>
  
  <p>My bat file:</p>
  
  <pre><code>xelatex --output-driver="xdvipdfmx -V 7 -q" final.tex
  xelatex --output-driver="xdvipdfmx -V 7 -q" final.tex
  call clean.bat
  </code></pre>