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?

1 Answer 1

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); } 
Sign up to request clarification or add additional context in comments.

6 Comments

Ok ok, I won't cheat again - will delete my response and upvote you :)
@MattRoberts actually I removed my downvote, but for future - that's unfair just write anything to make your answer appear first :)
That works just fine. Thanks. One last thing, is there a way to get when/if the process has finished executing?
Process.WaitForExit() will block the current thread until the process exits.
Not getting that under the Process intellisense
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.