Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
:: Valheim Server Control v2.0
:: https://gist.github.com/ErichHartmann/cafccde0a1736d741ec3e39ad620fa9a
:: fork of the more general https://pastebin.com/BRUbsGQh
:: https://steamcommunity.com/sharedfiles/filedetails/?id=2389009930
:: Updated 10 FEB 2021: Incorporate changes from Valheim 0.143.5
:: WARNING - ONLY FOR USE WITH WINDOWS 10 OS
:: You must install SteamCMD before running this script
:: See https://developer.valvesoftware.com/wiki/SteamCMD for directions
:: Download at https://steamcdn-a.akamaihd.net/client/installer/steamcmd.zip
SET programName=Valheim Server Control v2.0
SET gameName=Valheim
SET steamgameId=896660
SET steamUsername=anonymous
SET steamPassword=
:: Set your specific path variables - be wary of spaces in directory names
SET steamCMDPath=X:\0\bin\steamcmd\
SET runcmd=X:\0\bin\valheim\
:: Set your specific server variables
:: Ensure ports 2456-2458 are being forwarded to your server through your local router and firewalls
:: Minimum password length is 5 characters and cant be in the server name
SET gameServerName=My Server Name
SET gameWorldName=My World
SET gameServerPassword=My Secret Password
SET gameSaveDir=%USERPROFILE%\AppData\LocalLow\IronGate\Valheim
SET logName=%gameName%_%gameServerName%_server.log
@ECHO off
title %programName% - %gameName%
cls
COLOR 1f
CD /d "%runcmd%"
ECHO %gameSaveDir%
ECHO (%date%)(%time%) Init %programName% for %gameName% server named %gameServerName%
>> "%logName%" ECHO (%date%)(%time%) **************************************************
>> "%logName%" ECHO (%date%)(%time%) Init %programName% for %gameName% server named %gameServerName%
:menu
ECHO.
ECHO.
ECHO .d8888b. 8888888888 8888888b. 888 888 8888888888 8888888b.
ECHO d88P Y88b 888 888 Y88b 888 888 888 888 Y88b
ECHO Y88b. 888 888 888 888 888 888 888 888
ECHO "Y888b. 8888888 888 d88P Y88b d88P 8888888 888 d88P
ECHO "Y88b. 888 8888888P" Y88b d88P 888 8888888P"
ECHO "888 888 888 T88b Y88o88P 888 888 T88b
ECHO Y88b d88P 888 888 T88b Y888P 888 888 T88b
ECHO "Y8888P" 8888888888 888 T88b Y8P 8888888888 888 T88b
ECHO.
ECHO %gameName% Dedicated Server: %gameServerName%
ECHO.
ECHO WARNING - CTRL+C TO EXIT
:update
::Start steamcmd install and update terminal
ECHO.
ECHO (%date%)(%time%) Run %gameName% update via Steam using SteamCMD
>> "%logName%" ECHO (%date%)(%time%) Run %gameName% update via Steam using SteamCMD
ECHO.
start /wait /b %steamCMDPath%steamcmd +login %steamUsername% %steamPassword% +force_install_dir %runcmd% +app_update %steamgameId% validate +exit
:start
::Start the game server
ECHO.
ECHO (%date%)(%time%) Start %gameName% server - name: %gameServerName% - world: %gameWorldName% - password: %gameServerPassword%
>> "%logName%" ECHO (%date%)(%time%) Start %gameName% server - name: %gameServerName% - world: %gameWorldName% - password: %gameServerPassword%
ECHO.
start /high /wait valheim_server -nographics -batchmode -name "%gameServerName%" -port 2456 -world "%gameWorldName%" -password "%gameServerPassword%" -savedir %gameSaveDir% -public 1
:stop
::Stop the game server
ECHO.
ECHO (%date%)(%time%) Stop %gameName% server - name: %gameServerName% - world: %gameWorldName% - password: %gameServerPassword%
>> "%logName%" ECHO (%date%)(%time%) Stop %gameName% server - name: %gameServerName% - world: %gameWorldName% - password: %gameServerPassword%
ECHO Exit from %programName% (this console) is now OK
:goodbye
>> "%logName%" ECHO (%date%)(%time%) Exit %programName% for server %gameServerName% in %gameName%
@PDignam
Copy link

PDignam commented May 19, 2021

I like it --- nice --- well done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment