views:

597

answers:

3

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.

+6  A: 

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
That's another good way to do it.
Michael Todd
A: 

ask the user for input will stop the application flow , i think it was

string x = console.ReadLine();
From.ME.to.YOU
Good try, but this will still not guarantee that a prompt appears after the user started the application.
Michael Todd
While this answers the question, it does not in a way that satisfies tkyle requirements.
Jader Dias
Good idea, but what I was looking for was maybe a property or something to modify the way the console application window behaves.
tkyle
A: 

I found an answer to a similar question that satifies how to handle this question. See http://stackoverflow.com/questions/1173208/what-is-the-best-practice-for-combating-the-console-closing-issue/1173925#1173925

tkyle