I'm creating a simple console application under Windows XP and wondering if there is a way to keep the console window open after the application is run from the Windows run prompt, without putting an endless loop at the end of main(). I want the app to behave like it was run from the run prompt after first typing cmd.
Asked
Active
Viewed 1.0k times
7
-
Off the top of my head, no. This comes down to how the operating system fires off the application. You could shell out of the program rather than exit to make it _look_ like the program had finished, but it'll really still be running. – Michael Todd Dec 13 '09 at 17:40
2 Answers
7
ask the user for input will stop the application flow , i think it was
string x = console.ReadLine();

trrrrrrm
- 11,362
- 25
- 85
- 130
-
Good try, but this will still not guarantee that a prompt appears after the user started the application. – Michael Todd Dec 13 '09 at 17:43
-
While this answers the question, it does not in a way that satisfies tkyle requirements. – Jader Dias Dec 13 '09 at 17:44
-
Good idea, but what I was looking for was maybe a property or something to modify the way the console application window behaves. – tkyle Dec 13 '09 at 18:29
6
I think you'll need a second application which invokes the command prompt then tells it to execute your console application.
You can even do it with a single application that when called parameterless invokes the prompt and itself with a parameter that disables this behavior.

Jader Dias
- 88,211
- 155
- 421
- 625