Start, wait, start, wait till exit, then start batch file?

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
cnells2000
Posts: 2
Joined: 09 Jan 2021 15:28

Start, wait, start, wait till exit, then start batch file?

#1 Post by cnells2000 » 09 Jan 2021 17:35

Hello everyone! im trying to make a batch file that once started, it closes a program then loads another. and i want it to wait as long as possible until i manually exit out of the 2nd program before it starts the 1st program back again. please help

Code: Select all

timeout 3

taskkill /F /IM "gameex.exe" /T

timeout 2

start /wait "" "D:\Launchbox\bigbox.exe"

timeout 2

start "" "D:\GameEx\gameex.exe"


It seemed it worked to the letter but it did not wait until big box is exited before it started up gameex again. it just waited 2 seconds and then started gameex along side it so now they are both running simultaneously

I NEED it to wait until big box is fully exited before it loads gameex again. so if i happen to be on big box for 3 ,5, 7 hours, when i escape out of it. continue batch and load gameex.
Last edited by Squashman on 09 Jan 2021 17:56, edited 2 times in total.
Reason: MOD EDIT: Please use code tags.

Squashman
Expert
Posts: 4486
Joined: 23 Dec 2011 13:59

Re: Start, wait, start, wait till exit, then start batch file?

#2 Post by Squashman » 09 Jan 2021 17:57

Some programs will not respect the wait option of the START command. In your instance you really don't need use the START command at all.

Aacini
Expert
Posts: 1914
Joined: 06 Dec 2011 22:15
Location: México City, México
Contact:

Re: Start, wait, start, wait till exit, then start batch file?

#3 Post by Aacini » 10 Jan 2021 21:23

Try this:

Code: Select all

taskkill /F /IM "gameex.exe" /T

D:\Launchbox\bigbox.exe

start "" "D:\GameEx\gameex.exe"
This Batch file closes gameex.exe, then executes bigbox.exe, then waits until bigbox.exe is terminated, either manually or by any other method, to pass to the next line (that, by the way, is the standard method used by Batch files to execute commands: wait until a command ends in order to pass to the next).

After bigbox.exe ends, start gameex.exe...

Antonio

Post Reply