Skip to content

Autostart the server via .bat file

Mr. Zorn edited this page Feb 28, 2024 · 14 revisions

How to setup a bat file to schedule the start of the server

Faster will not manage and schedule server restarts etc for you, but you can take the command line provided by faster and use a .batch file which you can schedule with windows tools.

1.A How to get the commandline for the dedicated server.

In the Faster Program, in your server profile in the Profile Tab, you can find the commandline in the bottom. grafik

1.B How to get the commandline for the dedicated client / Headless Client.

Everytime you Start the server from the same page (Little Arrow in the bottom left), the Commandline will get dumped in your windows clipboard (The Ctrl + C / Ctrl + V Thingy).

If you dont use any HC, it will dump the normal server cmdline. If you do use any HC, it will dump the headless client cmdline.

Meaning, when you start the server with headless clients, the commandline for said HC will be provided to you this way.

grafik

If you use multiple Headless Clients, the HC Command line will the exactly the same, just start the server.exe with the hc cmd line multiple times.

2. Create the .bat file

The bat file should look like this

@echo off 
start PATHTOSERVER.EXE INSERTCOMMANDLINE HERE

Example

@echo off

start D:\A3\A3_Server\arma3serverprofiling_x64.exe -port=2402 "-config=D:\A3\A3_Server\Servers\_a8b840e3c50a4aa886a92f1a5461b82c\server_config.cfg" "-cfg=D:\A3\A3_Server\Servers\_a8b840e3c50a4aa886a92f1a5461b82c\server_basic.cfg" "-profiles=D:\A3\A3_Server\Servers\_a8b840e3c50a4aa886a92f1a5461b82c" -name=_a8b840e3c50a4aa886a92f1a5461b82c "-mod=@MODSMODSMODS;" -enableHT -netlog

:: start D:\A3\A3_Server\arma3serverprofiling_x64.exe -client -connect=127.0.0.1 -password=SERVERPASSWORD "-profiles=D:\A3\A3_Server\Servers\_a8b840e3c50a4aa886a92f1a5461b82c_hc1" -nosound -port=2402 "-mod=@MODSMODSMODS;" -enableHT

:: is to make a comment - in the example, I initially used hc here but decided against using them temporarily.

3. How to schedule execution of this .bat file

The easiest way is to put prevoius made .bat file in your autostart / autorun folder that gets executed everytime, your windows maschine is booting.

You'll be able to find the folder here:

C:\Users\USERNAME\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup

Alternative you can use the Windows Task Scheduler to start the .bat at given conditions. The Windows Task Scheduler also allows you to restart the box on a given time if need be.

4. Advanced Example BAT File with HC Support

@echo off

:: ### DEFINE VARIABLES ###
SETLOCAL
	:: Set Server Relevant Information
		set serverpath= D:\serverA3\Server1\arma3server_x64.exe

		set server_cmd_line= ##### INSERT YOUR SERVER CMD-LINE HERE #####

		set client_cmd_line= ##### INSERT YOUR HC CMD-LINE HERE #####

		set /A HC=2
		set /A delay=30

	:: Set Meta Data
		set game=ArmA3
		set modset=HAM Altis 90

:: ### START of CODE ###

Echo (%DATE% %TIME%) [ServerStart] [%game%] [%modset%] [HC: %HC%] Starting Dedicated Server...


start %serverpath% %server_cmd_line%

if %HC% GTR 0 FOR /L %%i IN (1,1,%HC%) DO call :Start_HC %%i

Echo.
Echo.
Echo (%DATE% %TIME%) [ServerStart] [%game%] [%modset%] [HC: %HC%] Done.

pause
goto:eof


:: ### END of CODE ###

:: ### DEFINE FUNCTIONS ###
:Start_HC
	timeout /t %delay%
    echo.
	Echo (%DATE% %TIME%) [ServerStart] [%game%] [%modset%] Starting Headless Client Nr. %~1 of %HC% ...
	start %serverpath% %client_cmd_line%
Clone this wiki locally