F5F Stay Refreshed Software General Software How to create a Windows batch file that starts a new program, then restarts the first one when the second one closes?

How to create a Windows batch file that starts a new program, then restarts the first one when the second one closes?

How to create a Windows batch file that starts a new program, then restarts the first one when the second one closes?

U
Udlu
Member
193
08-04-2026, 05:18 AM
#1
Hey everyone, I need some help with something. I'm not really a programmer or batch script maker so I wanted to ask here... I want to do this: (if I am already inside Program A where I can launch a custom script to call a .bat file from) When the .bat system starts up it would: 1- close Program A, then 2- start Program B. Then when Program B shuts down - Program A starts back up again. I'm not sure if this works or not, but any assistance is greatly appreciated! Windows 10 Pro
U
Udlu
08-04-2026, 05:18 AM #1

Hey everyone, I need some help with something. I'm not really a programmer or batch script maker so I wanted to ask here... I want to do this: (if I am already inside Program A where I can launch a custom script to call a .bat file from) When the .bat system starts up it would: 1- close Program A, then 2- start Program B. Then when Program B shuts down - Program A starts back up again. I'm not sure if this works or not, but any assistance is greatly appreciated! Windows 10 Pro

C
Cookie923Love
Junior Member
22
08-04-2026, 07:11 AM
#2
Create two batch files named batfile1.bat and batfile2.bat to run your programs instead of the default ones. In batfile1.bat, tell the computer to start c:\program_a\program_a.exe, wait a little bit so we can check if it works, then ask batfile2.bat to take over by running c:\program_b\program_b.exe and waiting again. If both work well, just remove the pause lines since you don't need to stop anytime soon.
C
Cookie923Love
08-04-2026, 07:11 AM #2

Create two batch files named batfile1.bat and batfile2.bat to run your programs instead of the default ones. In batfile1.bat, tell the computer to start c:\program_a\program_a.exe, wait a little bit so we can check if it works, then ask batfile2.bat to take over by running c:\program_b\program_b.exe and waiting again. If both work well, just remove the pause lines since you don't need to stop anytime soon.

D
DaniellePerry
Junior Member
23
08-04-2026, 07:52 AM
#3
Sounds pretty easy. Have you already tried something else? And did it stop working? By the way, you're going to end up in an endless loop.
D
DaniellePerry
08-04-2026, 07:52 AM #3

Sounds pretty easy. Have you already tried something else? And did it stop working? By the way, you're going to end up in an endless loop.

C
Char1ie_XD
Senior Member
578
08-06-2026, 06:17 AM
#4
Hey, I want to add a few things to this: what about Program A and Program B? When does Program B close? Why or how? It might make sense to use a PowerShell script for that instead. The details are really important here.
C
Char1ie_XD
08-06-2026, 06:17 AM #4

Hey, I want to add a few things to this: what about Program A and Program B? When does Program B close? Why or how? It might make sense to use a PowerShell script for that instead. The details are really important here.

X
xXNEONFROGXx
Junior Member
1
08-08-2026, 06:33 AM
#5
Program A is a front end for a virtual pinball machine called PinupPopper. Program B is a front end for retro games called BigBox. Long story short, the cabinet plays both types of games, but each front end works well on its own platform and does not work very well when trying to switch between them.

I asked some people who use the pinball side to write a batch file that turns off PinupPopper and turns on BigBox. I have already made this batch file and it runs fine. It uses the naming properties of the batch file so the front end knows what to do. When you start BigBox, you can select this batch file from the operator menu inside the front end. This takes me from A to B, but I still need help getting back from B to A.

It shouldn't be an infinite loop because it is a manual launch; when I exit Program A normally, the batch file won't start again automatically. Here is what works right now: SendPUPEvent.exe 11 timeout 3 cd c:\bigbox start "" bigbox.exe Thanks for any help you can give me!
X
xXNEONFROGXx
08-08-2026, 06:33 AM #5

Program A is a front end for a virtual pinball machine called PinupPopper. Program B is a front end for retro games called BigBox. Long story short, the cabinet plays both types of games, but each front end works well on its own platform and does not work very well when trying to switch between them.

I asked some people who use the pinball side to write a batch file that turns off PinupPopper and turns on BigBox. I have already made this batch file and it runs fine. It uses the naming properties of the batch file so the front end knows what to do. When you start BigBox, you can select this batch file from the operator menu inside the front end. This takes me from A to B, but I still need help getting back from B to A.

It shouldn't be an infinite loop because it is a manual launch; when I exit Program A normally, the batch file won't start again automatically. Here is what works right now: SendPUPEvent.exe 11 timeout 3 cd c:\bigbox start "" bigbox.exe Thanks for any help you can give me!

A
angelos51170
Junior Member
48
08-08-2026, 06:43 AM
#6
Make two batch files. Swap out the actual programs for your real ones and name them program_a.exe and program_b.exe. First file code: @echo batfile1 running c:\program_a\program_a.exe pause call batfile2.bat Second file code: @echo batfile2 running c:\program_b\program_b.exe pause call batfile1.bat After testing, if it works well, delete the lines with pause.
A
angelos51170
08-08-2026, 06:43 AM #6

Make two batch files. Swap out the actual programs for your real ones and name them program_a.exe and program_b.exe. First file code: @echo batfile1 running c:\program_a\program_a.exe pause call batfile2.bat Second file code: @echo batfile2 running c:\program_b\program_b.exe pause call batfile1.bat After testing, if it works well, delete the lines with pause.

X
xBohmaNx
Member
123
08-15-2026, 05:40 PM
#7
AutoHotkey sounds like a much easier option for these things.
X
xBohmaNx
08-15-2026, 05:40 PM #7

AutoHotkey sounds like a much easier option for these things.

P
pinkyenny
Member
64
08-20-2026, 06:05 AM
#8
Don't use the "call" command on that other batfile, or you'll get into trouble.
P
pinkyenny
08-20-2026, 06:05 AM #8

Don't use the "call" command on that other batfile, or you'll get into trouble.