How to hide cmd window while running a batch file?
I use the following code to run batch file
process = new Process();
process.StartInfo.FileName = batchFilePath;
process.Start();
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If proc.StartInfo.UseShellExecute is false, then you are launching the process and can use:
If proc.StartInfo.UseShellExecute is true, then the OS is launching the process and you have to provide a “hint” to the process via:
However the called application may ignore this latter request.
If using UseShellExecute = false, you might want to consider redirecting standard output/error, to capture any logging produced:
And have a function like
There’s a good page covering
CreateNoWindowthis on an MSDN blog.There is also a bug in Windows which may throw a dialog and defeat
CreateNoWindowif you are passing a username/password. For detailshttp://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=98476
http://support.microsoft.com/?kbid=818858