How to prevent programs from closing after batch file is executed?

0

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 127.0.0.1 -n 8 >nul
start "" "C:\Program Files\(My program here)"
PING 127.0.0.1 -n 8 >nul
start "" "C:\Users\(User name)\Desktop\(My program here)"
PING 127.0.0.1 -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.

user274546

Posted 2013-11-16T05:28:44.757

Reputation: 1

When I tested with your batch code, it is not closing. If you add pause as the last command, the terminal will not close. – Harikrishnan – 2013-11-16T09:10:35.293

@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. – Harikrishnan – 2013-11-16T09:12:42.067

Answers

1

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

The command prompt closes because the batch file has exited.

surfasb

Posted 2013-11-16T05:28:44.757

Reputation: 21 453