@Echo off
title RW Windows Server Installer v1.0 - Rebooter
color 1b
echo ------------------------------------
echo -  RW Auto Server Installer v1.0   -
echo -           By Yahgiggle           -
echo -  Auto Update, Backup and reboot  -
echo ------------------------------------

cd/
Call RWServerSettings\Settings.bat
start %Serverdrive%:\%ServerFolder%\Server\updater.cmd


:timeout
echo Auto Reboot and backup countdown started
timeout /t %Reboot% /NOBREAK 
goto Backup
pause
:Backup
type NUL > version.txt
for /f "tokens=2 delims==" %%a in ('wmic OS Get localdatetime /value') do set "dt=%%a"
set "YY=%dt:~2,2%" & set "YYYY=%dt:~0,4%" & set "MM=%dt:~4,2%" & set "DD=%dt:~6,2%"
set "HH=%dt:~8,2%" & set "Min=%dt:~10,2%" & set "Sec=%dt:~12,2%"
set "datestamp=%YYYY%%MM%%DD%" & set "timestamp=%HH%%Min%%Sec%"
set "fullstamp=%YYYY%-%MM%-%DD%_%HH%-%Min%-%Sec%"
:: back up server
taskkill /pid rw_server.exe /t /F
%Serverdrive%:\%ServerFolder%\Server\7z.exe a -r "%Serverdrive%:\%ServerFolder%\Backup\Server_%fullstamp%.zip" "%Serverdrive%:\%ServerFolder%\Server"
echo Search For And Delete Any Old Backup Files
forfiles /P "%Serverdrive%:\%ServerFolder%\Backup" /M *.* /D -30 /S /C "cmd /c del @FILE"
echo "-----------------------------------------------------------------------------------"
echo The Server has been backed up and rebooted 
start cmd.exe /c Start %Serverdrive%:\%ServerFolder%\Server\Boot.bat
goto timeout
pause










