So I have created a batch file that will run upon start-up that is made to run some programs automatically. The programs will all start and run fine, but after the batch file has finished all the commands and closes automatically, the programs all close too. I left the batch file on the desktop and created a shortcut of the batch file and put it in the start-up folder. Why do the programs close after the batch file closes? And how can I prevent this?

I am using Windows 7 Home Basic. My current batch file looks like this:

start "" "C:\Program Files\(My program here)"
PING -n 8 >nul
start "" "C:\Program Files\(My program here)"
PING -n 8 >nul
start "" "C:\Users\(User name)\Desktop\(My program here)"
PING -n 8 >nul

Is there something wrong with the commands I did here?

Also side question, does it matter whether or not you add "@echo off" at the start of every batch file? Does it also matter whether or not you add "exit" at the the end of the batch file?

If anyone could help with this, it would be greatly appreciated. I thought my batch file was good and all and I wouldn't have to run each program one by one upon start-up before doing anything else, but then this problem came up. Actually quite frustrating than what I had presumed; what a surprise.

  • When I tested with your batch code, it is not closing. If you add pause as the last command, the terminal will not close. Nov 16 '13 at 9:10
  • @echo off will turn off echoing the commands back to the command prompt. it is not mandatory. In the case of a batch file running directly, you don't have to add an exit. But when you run it from the command prompt, writing exit will cause the command prompt to close. Nov 16 '13 at 9:12

You'll need to add a PAUSE at the end of the batch file.

The command prompt closes because the batch file has exited.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.