Jump to content
  • Advertisement
Sign in to follow this  

[SOLVED]How to not close command window? C#

This topic is 2834 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I have code in c# that runs a .cmd file at some point in the program. Below is just an example of my code, but in my program there is some important information that user need to view in command window before it closes. Right now, the command windows closes automatically as soon as the commands are done. But I want to make it so the user closes the window manually after all the commands are done. Thanks!

String commandFile = "c:\\tempCopy.cmd";

StreamWriter SW;
SW = File.CreateText(commandFile);
SW.WriteLine("cd C:\\");
SW.WriteLine("copy C:\\file.txt C:\\anotherfile.txt");

Process cmd = new Process();
cmd.StartInfo.FileName = commandFile;


update: just used a "pause" at the end of command.

Share this post

Link to post
Share on other sites
You can also use Control-F5 to Run instead of F5 to Debug. It will leave the Console Window open after the program completes.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!