1.

Solve : creating batch file to start up programs after one another, not at the same time?

Answer»

Sorry I tried searching the forum and goggling this, but can't seem to get anything to work.

I have a basic batch file to startup some programs and it works fine. But I am now trying to make it where one program starts after the one before it is finished.

I tried the /wait and timeout .
timeout 10 works in Win7, but not on XP, haven't tried it on vista.
/wait starts up the first program and won't start the REST of the programs unless I close the one before it.

This is my basic batch file.
Code: [Select]@echo off

start "" "C:\Program Files\GIMP-2.0\bin\gimp-2.6.exe"
start "" "C:\Program Files\iTunes\iTunes.exe"
start "" "C:\Program Files\Corel\Corel Paint Shop Pro Photo XI\Corel Paint Shop Pro Photo.exe"
start "" "C:\Program Files\CoreFTP\coreftp.exe"

exit

Thank you for your assisstance.Not sure it's necessary to use start or wait or any sort of timeout. Try keeping it SIMPLE:

Code: [Select]@echo off

"C:\Program Files\GIMP-2.0\bin\gimp-2.6.exe"
"C:\Program Files\iTunes\iTunes.exe"
"C:\Program Files\Corel\Corel Paint Shop Pro Photo XI\Corel Paint Shop Pro Photo.exe"
"C:\Program Files\CoreFTP\coreftp.exe"

exit

Good luck. Quote

But I am now trying to make it where one program starts after the one before it is finished.

Quote
/wait starts up the first program and won't start the rest of the programs unless I close the one before it.

According to the first quote above, this is what you want, isn't it?


Quote from: Salmon Trout on July 08, 2011, 01:02:14 PM
According to the first quote above, this is what you want, isn't it?

no I want program 1 to startup ...
then once it has finished loading, I want to keep that program open and then
program 2 starts up, and so on.

I want all programs to be open, but in a sequence. is that possible?Use

start "" "program 1.exe"
PING 127.0.0.1 -n X >nul
start "" "program 2.exe"
PING 127.0.0.1 -n X >nul
start "" "program 3.exe"
PING 127.0.0.1 -n X >nul

[etc]

Replace X with a number, which is 1 more than the number of seconds delay you require, e.g. for 10 seconds delay replace X with 11.




Quote from: Salmon Trout on July 08, 2011, 01:25:43 PM
Use

start "" "program 1.exe"
PING 127.0.0.1 -n X >nul
start "" "program 2.exe"
PING 127.0.0.1 -n X >nul
start "" "program 3.exe"
PING 127.0.0.1 -n X >nul

[etc]

Replace X with a number, which is 1 more than the number of seconds delay you require, e.g. for 10 seconds delay replace X with 11.

-AH! Thank you very much!! That worked!
What does all that mean if you don't mind explaining?

I wonder why I have to use PING for XP
but Win7 reads it fine with timeout #?

very confusing for me :p

Much appreciated!Quote from: sehana on July 08, 2011, 01:30:46 PM
What does all that mean if you don't mind explaining?

When you use start like this ("title" can just be 2 quotes "" but cannot be left out) start "title" "program.exe" then the script starts program.exe and then returns at once, leaving program.exe running. So now you want to wait for a period of time before starting the next program. Ping can provide that delay and works with all versions of Windows. 127.0.0.1 is the IP address of the same computer that the script is running on. Its name is localhost. The ping command can take a parameter -n followed by a number which is the number of times to ping. The standard ping interval is 1 second. So ping -n 11 sends the first request and it gets a reply immediately, waits one second, sends the next request, gets an immediate reply, and so on – for the ten requests after the first. So to localhost those 11 times takes exactly 10 seconds. We redirect the output to nul so we don't see the ping command or its output on the screen.

Quote
I wonder why I have to use PING for XP but Win7 reads it fine with timeout #?

The reason why you cannot use timeout with XP is that the timeout.exe program was not included with XP. It was first introduced in Vista.

Thank You!!
I understand it much better now

I was wondering what the ping was for and didn't understand it, but now I understand, thank you Quote from: sehana on July 08, 2011, 02:36:11 PM
I was wondering what the ping was for and didn't understand it, but now I understand, thank you

http://en.wikipedia.org/wiki/Ping

Reading the OP's request I'm wondering why nobody has given the answer yet.

I've been doing the same thing in batch files for somewhere around 30 years, or so.

This would be my SOLUTION:

@Echo off
cls
call program1
call program2
call program3
Rem this batch file will close after program3 runs.


The rule for the "Call" command is that it will maintain the entire batch file in memory till the last program being called closes.
No line can execute till the previous line has completed.

Without the call command, the batch file would close when the first program runs and the subsequent programs would never run at all.

I do hope this helps.


PS: Or more specifically......

@Echo off
cls
Call "C:\Program Files\GIMP-2.0\bin\gimp-2.6.exe"
Call "C:\Program Files\iTunes\iTunes.exe"
Call "C:\Program Files\Corel\Corel Paint Shop Pro Photo XI\Corel Paint Shop Pro Photo.exe"
Call "C:\Program Files\CoreFTP\coreftp.exe"
Quote from: TheShadow on July 09, 2011, 08:42:02 AM
Reading the OP's request I'm wondering why nobody has given the answer yet.

You APPEAR to be answering a question other than the one the OP asked. If you read the whole thread, you will see that he (or she) wishes to start a program, wait a short while, then start a second program, then wait a short while, then start a third program, and so on. He does not wish to run the programs in sequence, closing one before running the next.

Quote
Without the call command, the batch file would close when the first program runs and the subsequent programs would never run at all.

This only applies to other batch files. You can start an executable program and depending on the syntax used for the start command, control will return to the batch script either at once or when the program has terminated.



Discussion

No Comment Found