PDA

View Full Version : How to run 2 programs with Batch Commands



Tally
10th February 2014, 15:43
I am writing a batch file with options to boot different types of server. I am stuck at booting first a dedicated server, then to parallel boot the client to that server. I am wondering if anyone knows the right syntax to do it.

This is what I have right now:


@echo off

set color=04e
color %color%

mode con: cols=80 lines=30

goto START

:START
echo __________________________________________________ ________
echo.
echo " _____ __ __ _ "
echo " | __ \ | \/ | | | "
echo " | | | | ___ _ __ ___ ___ _ __ | \ / | ___ __| | "
echo " | | | |/ _ \ '_ \` _ \/ _ \| '_ \| |\/| |/ _ \ / _ | "
echo " | |__| | __/ | | | | | (_) | | | | | | | (_) | (_| | "
echo " |_____/ \___|_| |_| |_|\___/|_| |_|_| |_|\___/ \__,_| "
echo " "
echo __________________________________________________ ________

goto MAKEOPTIONS

:MAKEOPTIONS
echo __________________________________________________ ________
echo.
echo Please select an option:
echo 1. Listen Server
echo 2. Dedicated Server
echo 3. Developers Server
echo.
echo 0. Exit
echo.
set /p make_option=:
set make_option=%make_option:~0,1%
if "%make_option%"=="1" goto LISTEN
if "%make_option%"=="2" goto DEDICATED & CLIENT
if "%make_option%"=="3" goto DEVELOPER
if "%make_option%"=="0" goto END
goto START


:LISTEN
echo.
echo.
@echo STARTING COD2 DEMONMOD LISTEN
@echo off

cd C:\Program Files (x86)\Activision\Call of Duty 2\
CoD2MP_s.exe +set fs_game mods/demon +exec mp-server.cfg +set sv_punkbuster 0 +map_rotate
goto END

:DEDICATED
echo.
echo.
@echo STARTING COD2 DEMOMOD DEDICATED
@echo off

cd C:\Program Files (x86)\Activision\Call of Duty 2\
CoD2MP_s.exe +set fs_game mods/demon +set dedicated 2 +set net_ip 86.26.148.175 +set net_port 28961 +exec mp-server.cfg +set sv_punkbuster 0 +map_rotate

:CLIENT
cd C:\Program Files (x86)\Activision\Call of Duty 2\
CoD2MP_s.exe +connect 86.26.148.175:28961
goto END

:DEVELOPER
echo.
echo.
@echo STARTING COD2 DEMOMOD DEVELOPER
@echo off

cd C:\Program Files (x86)\Activision\Call of Duty 2\
CoD2MP_s.exe +set fs_game mods/demon +set developer 1 +set developer_script 1 +exec mp-server.cfg +set sv_punkbuster 0 +map_rotate
goto END


:END
EXIT


What happens is, when I pick option 2, the dedicated server starts no problem, but I have to shut the server down before :CLIENT is executed.

Anyone know how to do it?

Mitch
10th February 2014, 16:35
What happens is, when I pick option 2, the dedicated server starts no problem, but I have to shut the server down before :CLIENT is executed.

Anyone know how to do it?

Maybe it works with the parameter allowdupe. (CoD2MP_s.exe allowdupe +set fs_game mods/demon...)

Edit: i get it now, you run the .bat and the code is still waiting until the application is finished and then it starts the other server.
See this: http://stackoverflow.com/questions/893203/bat-files-nonblocking-run-launch

Tally
10th February 2014, 16:40
Maybe it works with the parameter allowdupe. (CoD2MP_s.exe allowdupe +set fs_game mods/demon...)

Edit: i get it now, you run the .bat and the code is still waiting until the application is finished and then it starts the other server.

Yes, the batch code is waiting until the dedicated server is finished. Then, it starts :CLIENT. I want it to run BOTH at the same time. A parallel run command.

Mitch
10th February 2014, 16:44
What about:



start CoD2MP_s.exe +set fs_game mods/demon +set dedicated 2 +set net_ip 86.26.148.175 +set net_port 28961 +exec mp-server.cfg +set sv_punkbuster 0 +map_rotate

(http://stackoverflow.com/questions/893203/bat-files-nonblocking-run-launch)

Tally
10th February 2014, 17:00
No, I tried that. In fact, when googling, that forum link came up. It still waits for the dedicated server to shut down before proceeding to launch the client to the server IP.

I'm stumped. Been on it for 2 days now.

kung foo man
10th February 2014, 17:03
Just tested it, this workes like a charm (basically just Mitchs suggestions merged :D)



start CoD2MP_s.exe allowdupe +set dedicated 2
start CoD2MP_s.exe allowdupe +set dedicated 2


At least the second .exe needs "allowdupe", otherwise it will close itself.

Info: tested on Win8

Tally
10th February 2014, 17:15
Just tested it, this workes like a charm (basically just Mitchs suggestions merged :D)



start CoD2MP_s.exe allowdupe +set dedicated 2
start CoD2MP_s.exe allowdupe +set dedicated 2



At least the second .exe needs "allowdupe", otherwise it will close itself.

Info: tested on Win8

Jesus! So simple!

thanks guys :)

Ni3ls
10th February 2014, 17:23
what does allowdupe do?

Tally
10th February 2014, 17:29
what does allowdupe do?

Allows 2 or more instances of the same program.

Ni3ls
10th February 2014, 18:51
But I can run multiple COD2's on my laptop without this command. Or is it something else?

Tally
10th February 2014, 19:34
But I can run multiple COD2's on my laptop without this command. Or is it something else?

Actually, it is something else. After experimenting further, I found out that using allowdupe created some sort of wait time. And it was the wait time that was actually needed - not the expression allowdupe.

I ended up using this:


@echo off

set color=04e
color %color%

mode con: cols=80 lines=30

goto START

:START
echo __________________________________________________ ________
echo.
echo " _____ __ __ _ "
echo " | __ \ | \/ | | | "
echo " | | | | ___ _ __ ___ ___ _ __ | \ / | ___ __| | "
echo " | | | |/ _ \ '_ \` _ \/ _ \| '_ \| |\/| |/ _ \ / _ | "
echo " | |__| | __/ | | | | | (_) | | | | | | | (_) | (_| | "
echo " |_____/ \___|_| |_| |_|\___/|_| |_|_| |_|\___/ \__,_| "
echo " "
echo __________________________________________________ ________

goto MAKEOPTIONS

:MAKEOPTIONS
echo __________________________________________________ ________
echo.
echo Please select an option:
echo 1. Listen Server
echo 2. Dedicated Server
echo 3. Developer Server
echo.
echo 0. Exit
echo.
set /p make_option=:
set make_option=%make_option:~0,1%
if "%make_option%"=="1" goto LISTEN
if "%make_option%"=="2" goto DEDICATED
if "%make_option%"=="3" goto DEVELOPER
if "%make_option%"=="0" goto END
goto START


:LISTEN
echo.
echo.
@echo STARTING COD2 DEMONMOD LISTEN
@echo off

cd C:\Program Files (x86)\Activision\Call of Duty 2\
CoD2MP_s.exe +set fs_game mods/demon +exec mp-server.cfg +set sv_punkbuster 0 +map_rotate
goto END

:DEDICATED
echo.
echo.
@echo STARTING COD2 DEMOMOD DEDICATED
@echo off

cd C:\Program Files (x86)\Activision\Call of Duty 2\

START CoD2MP_s.exe +set fs_game mods/demon +set dedicated 2 +set net_ip 86.26.148.175 +set net_port 28961 +exec mp-server.cfg +set sv_punkbuster 0 +map_rotate

TIMEOUT 7
echo.
echo.
@echo LAUNCHING CLIENT TO SERVER
@echo off
START CoD2MP_s.exe +connect 86.26.148.175:28961
goto END


:DEVELOPER
echo.
echo.
@echo STARTING COD2 DEMOMOD DEVELOPER
@echo off

cd C:\Program Files (x86)\Activision\Call of Duty 2\
CoD2MP_s.exe +set fs_game mods/demon +set developer 1 +set developer_script 1 +exec mp-server.cfg +set sv_punkbuster 0 +map_rotate
goto END


:END
EXIT 0