Main Restorations Software Audio/Jukebox/MP3 Everything Else Buy/Sell/Trade
Project Announcements Monitor/Video GroovyMAME Merit/JVL Touchscreen Meet Up Retail Vendors
Driving & Racing Woodworking Software Support Forums Consoles Project Arcade Reviews
Automated Projects Artwork Frontend Support Forums Pinball Forum Discussion Old Boards
Raspberry Pi & Dev Board controls.dat Linux Miscellaneous Arcade Wiki Discussion Old Archives
Lightguns Arcade1Up Try the site in https mode Site News

Unread posts | New Replies | Recent posts | Rules | Chatroom | Wiki | File Repository | RSS | Submit news

  

Author Topic: Need a batch file to switch between two programs on exit from one  (Read 3864 times)

0 Members and 1 Guest are viewing this topic.

Turnarcades

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 1973
  • Last login:May 13, 2017, 08:14:29 am
  • Craig @ Turnarcades
    • Turnarcades
Hi. Just a quickie I hope someone can help me with.

I'm setting up a system running two games only (both PC games with .exe extensions). Rather than having a front-end I want to set it up so it automatically boots into the first game, but when this program exits it automatically starts the second game and vice versa, so quitting one game always launches the other one.

I'm thinking a batch file will do the trick, setting the Windows shell to launch the .bat file on startup (as I've done with other projects), but I just need to know what to put in it to do this?

codefenix

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 85
  • Last login:July 26, 2013, 10:53:44 am
    • My MAME Cabinet Build
Re: Need a batch file to switch between two programs on exit from one
« Reply #1 on: October 28, 2011, 06:38:07 pm »
Code: [Select]
@echo off

:rungame1
GAME1.EXE

:rungame2
GAME2.EXE

goto rungame1


JODY

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 548
  • Last login:June 08, 2025, 11:26:01 pm
  • After a long delay...the arcade is underway!
Re: Need a batch file to switch between two programs on exit from one
« Reply #2 on: October 28, 2011, 06:41:52 pm »
There are many sites with good details on Windows batch scripting.  If you haven't find some, do a Google search.

You can use this as a basic framework.  I put in pauses instead of running programs and echo statements so you can see that it works.  Save the following into a .bat plain text file (e.g. use Notepad):

:first
echo first
pause
goto second

:second
echo second
pause
goto first


Turnarcades

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 1973
  • Last login:May 13, 2017, 08:14:29 am
  • Craig @ Turnarcades
    • Turnarcades
Re: Need a batch file to switch between two programs on exit from one
« Reply #3 on: October 28, 2011, 07:55:46 pm »
Thanks for the replies. So JODY, I just need to substitute the 'pause' entries with the exe file locations? I've created and used batch files before, it's just the actual logic of the entries that baffle me a bit.

Codefenix, yours is different, would this always switch back and forth between the games or just end after relaunching game 1?

JODY

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 548
  • Last login:June 08, 2025, 11:26:01 pm
  • After a long delay...the arcade is underway!
Re: Need a batch file to switch between two programs on exit from one
« Reply #4 on: October 28, 2011, 09:00:48 pm »
The first example runs the first game then upon exit would run the second.  After exiting the second, it loops back to the top and runs the first one again.

Mine had some unneeded lines.  The goto second isn't needed as it would fall into that part anyway.  Just wanted to show you some syntax.  Basically you can create sections and use goto statements to jump around. 

Turnarcades

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 1973
  • Last login:May 13, 2017, 08:14:29 am
  • Craig @ Turnarcades
    • Turnarcades
Re: Need a batch file to switch between two programs on exit from one
« Reply #5 on: October 29, 2011, 06:50:21 am »
Ok thanks, I'll give them a try! Reminds me of my days messing with Speccy basic.

Thenasty

  • Trade Count: (+17)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 4420
  • Last login:Today at 12:07:47 am
    • Thenasty's Arcademania Horizontal/Vertical monitor setup.
Re: Need a batch file to switch between two programs on exit from one
« Reply #6 on: October 29, 2011, 10:37:11 am »
@echo off
:Games
game1.exe
game2.exe
goto games



Thenasty's Arcademania Horizontal/Vertical setup.
http://forum.arcadecontrols.com/index.php?topic=26696.0

Free VGA Breakout Cable
http://forum.arcadecontrols.com/index.php?topic=38228.0

Ultimate All in One Coin Mech write up (Make your own)
http://forum.arcadecontrols.com/index.php?topic=19200.0

eds1275

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 2165
  • Last login:July 21, 2025, 05:34:15 pm
  • Rock and Roll!
Re: Need a batch file to switch between two programs on exit from one
« Reply #7 on: October 31, 2011, 12:54:48 pm »
!!!! When I was a kid, I was obsessed with programming. Unfortunately it was on a commodore 64. By the time I had gotten good enough at it to start designing my own stuff, it was obsolete. This doesn't look too far off from my commodore days! Maybe I should have kept up with it!