4

I have this running from my c# winforms app:

string ExecutableFilePath = @"Scripts.bat";
string Arguments = @"";

if (File.Exists(ExecutableFilePath )) {
    System.Diagnostics.Process.Start(ExecutableFilePath , Arguments);
}

When that runs I get to see the cmd window until it finishes.

Is there a way to get that to run without showing it to the user?

Ian R. O'Brien
  • 6,682
  • 9
  • 45
  • 73
sd_dracula
  • 3,796
  • 28
  • 87
  • 158

1 Answers1

9

You should use ProcessStartInfo class and set the following properties

  string ExecutableFilePath = @"Scripts.bat";
  string Arguments = @"";

  if (File.Exists(ExecutableFilePath ))
  {
       ProcessStartInfo psi = new ProcessStartInfo(ExecutableFilePath , Arguments);
       psi.UseShellExecute = false;
       psi.CreateNoWindow = true;
       Process.Start(psi);
  }
Steve
  • 213,761
  • 22
  • 232
  • 286