Sign in with
Sign up | Sign in
Your question

How can I make a batch file that has different launch options?

Last response: in Applications
January 4, 2013 6:40:50 AM

I bought battlefield 2 off steam, and I want to have 3 or 4 installations; 1 untouched and the rest with different mods.

I want to make a batch file that has something along the lines of "Press 1 for...., 2 for.. etc"

If I do this, then I can convert the batch to an exe, rename it to BF2.exe and replace the original, therefore letting me launch different installations of BF2 while still counting them towards my play time (Rather than adding non steam shortcuts)

What commands would I need? Thanks!

Best solution

a b L Programming
January 4, 2013 6:55:29 AM

Well for starters what you are trying to do won't work. You can't rename a batch script to a .exe and expect it to work. Windows expects that anything with a .exe extension will be a binary executable, but yours is just a text file.
January 4, 2013 6:59:25 AM

I have a program that converts batches to EXEs, and it works fine. And also I think I found the code I was looking for

EDIT: Disregard this thread, I found the commands I needed and was able to edit them accordingly :D 


ECHO --------------------------------------------------
ECHO Battlefield 2 Mod Launcher
ECHO --------------------------------------------------
ECHO 1 - Battlefield 2 (No Mods)
ECHO 2 - Battlefield 2 (Project Reality)
ECHO 3 - Battlefield 2 (Mod 3)
ECHO 4 - Battlefield 2 (Mod 4)
SET /P M=Type 1, 2, 3, or 4 then press ENTER:
IF %M%==3 GOTO 3
IF %M%==4 GOTO 4
cd C:\Program Files (x86)\Steam\steamapps\common\Battlefield 2\1\
start BF2.exe
cd C:\Program Files (x86)\Steam\steamapps\common\Battlefield 2\2\
start BF2.exe
cd C:\Program Files (x86)\Steam\steamapps\common\Battlefield 2\3\
start BF2.exe
cd C:\Program Files (x86)\Steam\steamapps\common\Battlefield 2\4\
start BF2.exe
Related resources
January 4, 2013 7:08:30 AM

Best answer selected by Bl00dyMurd3r.
January 19, 2013 1:32:36 PM

If you put an @ in front of ECHO OFF, it disables ECHO for that line.
- This is why so many batch files start with @ECHO OFF, instead of ECHO OFF followed by CLS.
- For batch files under 8 lines put @ in front of every line
- In yours it means you won't have to call CLS (Clear Screen) immediately afterwards to 'hide' the output.
- You've also left out quotes in the directory names (they have a space in them), which for CHDIR (CD) isn't a major issue as the Windows Command Prompt somewhat auto-corrects, it's still a potential cause of problems down the track.

If you make a keyboard input error it might fall through to your :NOMODS label too.
That and there's no way (within the batch file anyway) to exit it cleanly.

Batch files are freaking awesome, I used to love writing them!

The only issue with your idea that I can immediately think of is that if you verify the steam cache it might look at the 4 folders, your 'different' BF2.EXE and freak out a little.