• Announcements

    • Brentonator

      Forum Rules (Please Read)

      Hello everyone and welcome to the No More Room In Hell Forums! We greatly appreciate your interest and support. Please feel free to begin post and become a part of this community. But please make sure that you read and understand the following rules so things can stay as clean and as orderly as possible around here. These rules are expected to be follow by any and all members at all times. Disobeying these rules will result in disciplinary action by a moderator. #1. Off color remarks are acceptable but can be deemed inappropriate at the discretion of the moderators. #2. Flaming and disrespecting other members of this community or this mod is strictly prohibited. #3. Please do not post links relating to warez or illegal downloading. #4. No offensive content is to be posted (gore, dead babies, porn). #5. Please do not spam topics to increase your post count. #6. No excessively large signatures. Signatures that violate this will be modified. #7. Signatures are not to be used as a spamming tool. If your signature's sole purpose is to annoy or distract other members, it will be removed. #8. Please do your part to be as friendly, respectful, and helpful to anyone and everyone on this forum. #9. Your posts may be removed at any time at our sole discretion. #10. Remember the terms of your registration...a copy is posted below but may not represent the latest version of our terms of use. #11. No advertising other communities or products. Have fun.
Gringos

NMRIH server protect batchfile

3 posts in this topic

After using several srcds servers and a standar script to restart when it crashes i descided it was time for a more advanced take.

This batchfile checks the server process on the name of the server or when starting up on "SOURCE DEDICATED SERVER" I use it only when i have the NMRIH server running as the only server, otherwise it cannot detect if the process is of another gametype. It will continue to check every 5 seconds, if the server has crashed or you exited by typing 'quit' it will kill the process(es) and restart the server. The checks are displayed using the Batch title.

Instructions and disclaimer:

Use it at your own risk, although it works great for me.

Replace the "YOURSERVERNAME" with the name of your server as it will show in the title of your srcds window when the server is completely started. (e.g. Gringo's server)

Replace the "YOURS*" in the "taskkill" line, this is the start of the servername (e.g. Gringo*)

Be careful that no other programs will start with this line, because this line will kill all processes starting with it.

After the ":srcds" you can set your own startup options to start the server.

Title NMRIH Server script
cls
:check
@echo off
REM Check for running srcds.exe with Windowname
Title NMRIH Server script - Checking Server status

:check1
REM CHECK IF SERVER IS BUSY THEN THE TITLE WILL DISPLAY "SOURCE DEDICATED SERVER"
tasklist /v /FI "IMAGENAME eq srcds.exe" 2>NUL | find /I /N "SOURCE DEDICATED SERVER">NUL 
if %ERRORLEVEL%==0 (
Title NMRIH Server script - Server is still Restarting...
goto check1 )

REM CHECK FOR RUNNING FUNCTIONAL SERVER
tasklist /v /FI "IMAGENAME eq srcds.exe" 2>NUL | find /I /N "YOURSERVERNAME">NUL
if %ERRORLEVEL%==1 goto error


ping 192.0.2.2 -n 1 -w 1000 >NUL

Title NMRIH Server script - Server is Running
ping 192.0.2.2 -n 1 -w 4000 >NUL
goto check

:srcds
REM Change the following line with your startup line for the server:
C:\Windows\System32\cmd.exe /c start "NMRIH Server" /high "C:\YOURSERVERPATH\orangebox\srcds.exe" -console -game nmrih -port 27019 +map nms_storestand.bsp
ping 192.0.2.2 -n 1 -w 5000 > nul
echo (%time%) NOTICE:  srcds restarting
goto check

:error
Title Title NMRIH Server script - Server is Restarting...
echo (%time%) WARNING: srcds closed or crashed, restarting.
echo (%time%) NOTICE:  Killing srcds.exe processes if they exist
REM Kill all processes, SRCDS that do not have windowtitle "YOURS*"
taskkill /F /FI "WINDOWTITLE ne YOURS*" /FI "WINDOWTITLE ne SOURCE*" /IM srcds.exe>NUL
goto srcds
Hope it helps.
With regards Gringos
Edited by Gringos

Share this post


Link to post
Share on other sites

Save it as a batch file. (e.g. nmrih.bat), you can use a .txt as template and change the extension to .bat

Execute it to start the server

Edited by Gringos

Share this post


Link to post
Share on other sites

Thanks.

Replace the "YOURS*" in the "taskkill" line, this is the start of the servername (e.g. Gringo*)

Be careful that no other programs will start with this line, because this line will kill all processes starting with it.

To be safe why not use full name for this option? or it won't work?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now