7

"subfolder\program to run.exe" works but keeps the command prompt open.

I would like the command prompt to close but keep the application open, how do I do this.

2 Answers 2

8

The other answer works fine for me in XP, but you can also try the following instead:

start "" "subfolder\program to run.exe" & exit

5
  • This worked but the answer by benshepherd doesn't...are you able to explain why?
    – Cheetah
    Apr 6, 2013 at 18:24
  • Not sure. As I mentioned above, the other one worked fine too for me on XP, and I tested both methods with calc as well as a non-Microsoft program. Perhaps the problem lies with the specific program you're testing with.
    – Karan
    Apr 6, 2013 at 21:11
  • I guess I’m just pushing the question a few inches, but it seems to come down to whether you get your “Command Prompt” prompt back immediately after you type program_name, or do you have to wait until it terminates. Typically, if you type calc or notepad, you get your prompt back immediately. But I’ve seen it work the other way for some programs (e.g., Microsoft Office) on some machines. I don’t know why. (continued…) Jun 21, 2013 at 23:46
  • … And, if you have a program that locks up the prompt, any commands you put after it (e.g., & exit) will be processed only after the program finishes. And the start command, among other things, seems to “detach” the program from the command interpreter, allowing you to get the prompt back (and, hence, allowing the exit command to be processed) immediately. Jun 21, 2013 at 23:47
  • @Scott: start of course can /wait for a program to terminate as well. You're most likely correct in that the OP's program probably wasn't returning control back to the command prompt for the exit command to be executed successfully.
    – Karan
    Jun 21, 2013 at 23:50
6

You can append & exit to the command you run. So for instance, from the command prompt:

calc & exit

runs Calculator and closes the commmand prompt window.

3
  • 1
    This does not work. The command prompt is still open whilst the application is.
    – Cheetah
    Mar 20, 2013 at 15:15
  • What OS are you using? It works for me in Win7 and XP. Mar 25, 2013 at 9:53
  • I am running Windows XP
    – Cheetah
    Apr 6, 2013 at 18:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .