1

I need a batch file that I can leave running, and if "Unturned.exe" is not running do START "" /B "C:\Users\Administrator\Desktop\1.lnk", and then idle, scan, and wait for it to shutdown again in a loop.

This is what I am using now but there is no communication between this and the server for people to know that it is about to restart, and I only run one server now.

Please note that the server has a Server MSG at 55 mins, 57 and 59 mins. The server will auto shutdown after 1 hour. I only want the script to scan for the Unturned.exe and if it's not running to then start from the desktop shortcut. I don't need it to count down the hour like my old script and only need it to run in background so I dont have to worry about it.

@echo off
cls
color B


:loop

echo ===========================================================
echo ===========================================================
echo ======== UNTURNED SERVER RESTART SCRIPT By FATBOI =========
echo ===========================================================
echo ===========================================================

@timeout /T 1 /nobreak >NUL
echo ===========================================================
echo Killing all servers for restart...
echo ===========================================================

@timeout /T 1 /nobreak >NUL
taskkill /f /im Unturned.exe
echo ===========================================================
echo All servers have been killed
echo ===========================================================

echo ===========================================================
echo Servers starting...
echo ===========================================================
start "" /b "C:\Users\Administrator\Desktop\1.lnk"
@timeout /T 30 /nobreak >NUL


cls

echo ===========================================================
echo ===========================================================
echo ===== UNTURNED SERVER RESTART SCRIPT By JoeCooper2015 =====
echo ===========================================================
echo ==================Server Restart Time======================
echo ===========================================================
time /T
echo ===========================================================
echo ===========================================================

REM Every 4 hours kill and start servers. note 1H = 3600 seconds
REM use timeout then goto loop
@timeout /T 3600 /nobreak

goto loop
1
  • Joe - Did you see my below answer? Did it help you any or can I adjust further to help get it to work as you need it to? If it worked, could you turn the grey check mark to the upper left of my answer to green and accept it? I did adjust it per your comment below after that comment so I'm still waiting for feedback. I do this stuff for a living so I can help if you communicate with my and give me some feedback so I can understand further, etc. Thank Joe!! Nov 15, 2019 at 17:31

1 Answer 1

0

Need assistance with an existing batch file

I need a batch file that I can leave running, and if "Unturned.exe" is not running do START "" /B "C:\Users\Administrator\Desktop\1.lnk", and then idle, scan, and wait for it to shutdown again in a loop.

Give the below script a shot and test to confirm it works as expected, and confirm this resolves the issue.

Note: If the 30 second wait after running the START "" /B "C:\Users\Administrator\Desktop\1.lnk" command is not long enough after killing the Unturned.exe process, then you may need to increase that number to add more seconds than 30 (e.g 60). Perhaps sometimes 30 seconds is sufficient then at other times when the server is under heavier load that is not enough time. This is something to consider if you still have trouble with this.

@ECHO OFF
CLS
COLOR B

:loop
PING -n 5 127.0.0.1 >NUL
TASKLIST | FINDSTR /I "Unturned.exe"
IF ERRORLEVEL 1 (GOTO StartUnturn) ELSE (GOTO loop)

:StartUnturn
ECHO ===========================================================
ECHO Servers starting...
ECHO ===========================================================
START "" /B "C:\Users\Administrator\Desktop\1.lnk"
PING -n 30 127.0.0.1 >NUL
GOTO loop

Additional Reading and Resources

1
  • So the server Has a Server MSG at 55 mins, 57 and 59 mins. The server will auto shutdown after 1 hour. i only want the script to scan for the Unturned.exe and if its not running start from the desktop shortcut. i dont need it to count down the hour like my old one just run in background so i dont have to worry about it.
    – JoeCooper
    Jan 23, 2016 at 5:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .