Jump to content
Dateranoth

Conan Exiles Server Utility

Recommended Posts

Conan Server Utility (Latest Version will always be here)

[Latest Releases]

Automate your Conan Server Management with this Utility! Written using AutoIT with full Source available.

UPDATE CHECK REQUIRES THE SCRIPT CAN READ FROM http://steamcommunity.com/games/440900/rss/

  • Conan Server Utility Features
    • Manage Multiple servers with multiple Utilities (See V2.2.2.0 Update)
    • Monitors for crashes and Restarts Server if process closes
    • Optionally Enable fix to close DLL error that comes up if Steam is open when starting server
    • Optionally Disable MULTIHOME to fix some connection problems
    • Optionally Check Latest Version Using SteamCMD for automatic Updates (In 5 to XX minute intervals)
    • Optionally Restart the server daily at a certain time (Up to 6 different times through the day)
    • Optionally Use Remote Restart Utility to Restart server remotely using unique passwords (Optionally set Users) and port
    • Optionally Use SteamCMD to automatically update server
    • Optionally run verification every time SteamCMD is ran
    • Optionally restart server on excessive memory use.
    • Optionally use Discord to notify channel before restart using Webhook
    • Optionally use Twitch to notify channels before restart using IRC
    • Log Excessive memory use. Set to a very large number if you don't wish to log anything
    • Set Game Name, Game IP, Game port, max players, Server Password, and Admin Password
    • Rotate X number of logs created by utility every X hours
  • Conan Remote Restart Features
    • If enabled on the server, use to remotely restart the server.
    • Set Password in INI file to save, or type each time.
    • Restart using IP or Domain Name

This utility, when SteamCMD and daily restarts are enabled, will keep the server up to date on a daily basis.  You can also use  SteamCMD and remote restart to update the server anytime you send the restart request. If CheckForUpdate is enabled this utility will parse the RSS for Conan to look for PATCH headers every X minutes based on what you set.  If it finds a new header it will restart to update the server.

A few things to note. The Game Server IP will be the IP you wish to bind to. This may be a local IP if your server is behind a router.  Also, the game can take a long time to gracefully shut down. So, when the restart is initiated, the utility attempts to gracefully shut down the server. If the server will not shut down gracefully after 1 minute the process is forcefully closed. When SteamCMD is used, a full cycle from the time the command is sent to the time the server is back on line can take 10 minutes or more.  Finally, the remote restart port needs to be allowed through your firewall.

 

All source has been moved to GitHub. I was driving myself crazy trying to keep up with changes in a flat file format. This grew a bit more than I expected.

SOURCE ON GITHUB

Share this post


Link to post
Share on other sites

Updated to V1.1

This version includes the known server commands and the ability to set the processor affinity for the server. This was a personal use for me to prevent issues running along side my Rust server.

 

@ECHO OFF
::By Dateranoth - January 31, 2017
::Used by https://www.gamercide.org on their server.
::Feel free to change, adapt, and distribute
::DecToHex conversion code FROM http://stackoverflow.com/users/778560/aacini

::V1.1-Added known server options. Added ability to change processor affinity.-------::
::-----------------------------------------------------------------------------------::
::V1.0-Initial Version Created. Simple Loop Script to download server files from-----::
::Steam. No useage other than that yet.----------------------------------------------::

::-----------------------------------------------------------------------------------::
::--------------------User Variables-------------------------------------------------::
::-----------------------------------------------------------------------------------::

::Set RustDedicated.exe Directory (Be sure to include Trailing Slash)
SET ServerPath=C:\Game_Servers\Conan_Exiles_Server\

::Set Time between server Failed or Stopped and Server Restarted (in seconds)
SET Timer=10

::---------------------------------------------------------------------------------------::
::--------------------Server Settings------No space after = -----------------------------::
::---------------------------------------------------------------------------------------::

::-SERVER NAME CANNOT BE SET FROM THIS LAUNCHER. You need to set it in your game folder--::
::-Open SERVER\ConanSandBox\Saved\Config\WindowServer\Engine.ini ------------------------::
::-If not there add [OnlineSubsystemSteam] to the bottom of the file---------------------::
::-Below that Add ServerName=YOURSERVERNAME ---------------------------------------------::
::-For a server Password (to prevent public access) Add ServerPassword=YOURPASS ---------::
::-Save the file. The remainder of settings are in ServerSettings.ini - Modify as needed-::


::Set the IP for the Server.
SET IP=192.168.0.45

::Set the Game Port for the Server (This is what players will connect to)
SET GamePort=27015

::Set the Query Port for the Server (Admin purposes? Not sure yet)
SET QueryPort=27016

::Set the Maximum Players Allowed on your server.
SET MaxPlayers=30

::Set the Admin Password. This is what you will use to get administrator rights from the menu.
SET AdminPass=CHANGEME

::Enable Console. With this disabled your server still runs and logs, but you get no visible window
SET EnableConsole=yes

::-----------------------------------------------------------------------------------::
::--------------------Update Server on Each Restart----------------------------------::
::-----------------------------------------------------------------------------------::

::Update and Verify server files on each restart using SteamCMD? (yes or no)
SET EnableUpdate=yes

::Set steamcmd.exe Directory (Be sure to include Trailing Slash)
SET SteamCmdPath=C:\Game_Servers\SteamCMD\

::---------------------------------------------------------------------------------------::
::--------------------Affinity Settings------No space after = ---------------------------::
::Use these to set the affinity of your Conan Server if needed. You will need to enter---::
::the affinity in binary by number of cores. To use Cores 0,1,&2 in a Four Core System---::
::you would set bin=0111 ----To use cores 0,2,4,5 in a 6 core system set bin=110101 -----::
::First binary number is the last core. Last binary number is the first core ------------::
::Make sure there is a 1 or 0 for ALL available cores, including hyper threads. If you---::
::leave anything out it will set the cores incorrectly-----------------------------------::
::---------------------------------------------------------------------------------------::

::Enable setting affinity for the server. Leave this no if you wish to use all cores (yes or no)
SET EnableAffinity=no

::Set which cores you wish to use. Refer to the information above.
SET bin=11111100

::------------------------------------------------------------------------------------------------------------------------------::

::!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!No Setting Changes Below Here!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!::

::------------------------------------------------------------------------------------------------------------------------------::
:Start
title Conan Server Utility
endlocal
setlocal

:AffinityCheck
IF /i %EnableAffinity%==yes (
set hex=
goto AffinityStart 
) ELSE (
set hex=
goto LogCheck
)

:AffinityStart
call :bin2hex hex=%bin%
echo hex: %hex%
set hex=/AFFINITY %hex%
goto :LogCheck

:bin2hex hexVar=binValue
setlocal EnableDelayedExpansion

for %%a in (0000-0;0001-1;0010-2;0011-3;0100-4;0101-5;0110-6;0111-7;1000-8;1001-9;1010-A;1011-B;1100-C;1101-D;1110-E;1111-F) do (
   for /F "tokens=1,2 delims=-" %%b in ("%%a") do (
      set "hextable[%%b]=%%c"
   )
)

set "hex="
set "bin=000%~2"
:bin2hexloop
   set "hex=!hextable[%bin:~-4%]!%hex%"
   set "bin=%bin:~0,-4%"
if defined bin if "%bin:~3%" neq "" goto bin2hexloop
endlocal & set "%~1=%hex%"
set hex=/AFFINITY %hex%
goto :LogCheck

:LogCheck
setlocal
IF /i %EnableConsole%==yes (
SET log=-log
) ELSE (
SET log=
goto UpdateCheck
)

:UpdateCheck
IF /i %EnableUpdate%==yes (goto UpdateStart) ELSE (goto GameStart)

:UpdateStart
::Update if updates available and Verify Rust Server via steamcmd.
cd /d "%SteamCmdPath%"
"%SteamCmdPath%"steamcmd.exe +@ShutdownOnFailedCommand 1 +@NoPromptForPassword 1 +login anonymous +force_install_dir %ServerPath% +app_update 443030 validate +quit
goto GameStart

:GameStart
ECHO.
ECHO Starting Server Loop.
ECHO This window needs to stay open to properly monitor server.
ECHO.
start "Conan Server" /D "%ServerPath%ConanSandbox\Binaries\Win64" %HEX%/WAIT "%ServerPath%ConanSandbox\Binaries\Win64\ConanSandboxServer-Win64-Test.exe" ConanSandBox?Multihome=%IP%?GameServerPort=%GamePort%?GameServerQueryPort=%QueryPort%?MaxPlayers=%MaxPlayers%?listen?AdminPassword=%AdminPass% -nosteamclient -game -server %log%
::start "Conan Server" /D "%ServerPath%" %HEX%/WAIT "%ServerPath%ConanSandboxServer.exe" ConanSandBox?Multihome=%IP%?GameServerPort=%GamePort%?GameServerQueryPort=%QueryPort%?MaxPlayers=%MaxPlayers%?listen?AdminPassword=%AdminPass% -nosteamclient -game -server %log%
endlocal
goto RemainingLoop


:RemainingLoop
::Checks if timer has counted down to 0. If so restarts backup
setlocal enableDelayedExpansion
for /l %%N in (%Timer% -1 1) do (
  SET /a "min=%%N/60, sec=%%N%%60, n-=1"
  if !sec! lss 10 SET sec=0!sec!
  cls
  choice /c:CR1 /n /m "Server Restart in !min!:!sec! - Press R to Restart Server Now, or C to Cancel. " /t:1 /d:1
  if not errorlevel 3 goto :CheckAnswer
)

:CheckAnswer
if errorlevel 2 (goto Start) else (goto End)

::Shut Down The Batch File.
:End
choice /c:YN /m "Do you really want to quit"
If Errorlevel 2 goto Start
If Errorlevel 1 goto Shutdown

:Shutdown
taskkill /f /im "ConanSandboxServer-Win64-Test.exe"
taskkill /f /im "ConanSandboxServer.exe"
endlocal
Exit

::Here in case of any major errors.
:CatchAllEnd
endlocal
pause
Exit

 

Share this post


Link to post
Share on other sites

Question, i know nothing about this stuff but if i show my admin this he can copy paste so when hes  not here to update server this will automatically update it for us and allow us to continue playing. Am i correct?

Share this post


Link to post
Share on other sites

@axg3097

It will only update if it restarts. I made another piece of code today that will allow remote restarts of the server. 

 

I wont be home for several hours, but when I get home I will post it. 

 

It will do all the things this batch does plus restart daily, log excess memory use, restart on too much memory if you wish, and allow for remotely restarting the server using a password. 

 

The current batch file only runs and monitors the server. Once you start it will check for an update but will not check again until the server is stopped manually. 

Share this post


Link to post
Share on other sites

Completely redone the utility. Written using AutoIT instead of batch. This utility has much more features than the previous one.

  • Conan Server Utility Features
    • Set Game IP, game port, max players, and Admin Password
    • Log Excessive memory use. Set to a very large number if you don't wish to log anything
    • Optionally restart server on excessive memory use.
    • Optionally Use SteamCMD to automatically update server
    • Optionally Use Remote Restart Utility to Restart server remotely using unique password and port
    • Optionally Restart the server daily at a certain time
  • Conan Remote Restart Features
    • If enabled on the server, use to remotely restart the server.
    • Set Password in INI file to save, or type each time.

This utility, when SteamCMD and daily restarts are enabled, will keep the server up to date on a daily basis.  You can also use  SteamCMD and remote restart to update the server anytime you send the restart request.

A few things to note. The Game Server IP will be the IP you wish to bind to. This may be a local IP if your server is behind a router.  Also, the game can take a long time to gracefully shut down. So, when the restart is initiated, the utility attempts to gracefully shut down the server. If the server will not shut down gracefully after 1 minute the process is forcefully closed. When SteamCMD is used, a full cycle from the time the command is sent to the time the server is back on line can take 10 minutes or more.  Finally, the remote restart port needs to be allowed through your firewall.

 

Downloads

Complete Version 2.0 including Source

Conan Server Utility V2.0

Conan Server Remote Restart Utility V2.0

Conan Server Utility V2.0 Source

Conan Server Remote Restart Utility V2.0 Source

 

V2.0 Server Utility Source

Spoiler

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=favicon.ico
#AutoIt3Wrapper_Res_Comment=By Dateranoth - Feburary 4, 2017
#AutoIt3Wrapper_Res_Description=Utility for Running Conan Server
#AutoIt3Wrapper_Res_Fileversion=2.0
#AutoIt3Wrapper_Res_LegalCopyright=Dateranoth @ https://gamercide.org
#AutoIt3Wrapper_Res_Language=1033
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
;By Dateranoth - Feburary 4, 2017
;Used by https://gamercide.com on their server
;Feel free to change, adapt, and distribute

#include <Date.au3>
#include <Process.au3>
#include <MsgBoxConstants.au3>
Opt("WinTitleMatchMode", -2) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase

;User Variables
If FileExists("ConanServerUtility.ini") Then
   Local $g_IP = IniRead("ConanServerUtility.ini", "Game Server IP", "ListenIP", "127.0.0.1")
   Local $GamePort = IniRead("ConanServerUtility.ini", "Game Server Port", "GamePort", "27015")
   Local $AdminPass = IniRead("ConanServerUtility.ini", "Admin Password", "AdminPass", "yOuRpaSHeRe")
   Local $MaxPlayers = IniRead("ConanServerUtility.ini", "Max Players", "MaxPlayers", "20")
   Local $serverdir = IniRead("ConanServerUtility.ini", "Server Directory. NO TRAILING SLASH", "serverdir", "C:\Game_Servers\Conan_Exiles_Server")
   Local $UseSteamCMD = IniRead("ConanServerUtility.ini", "Use SteamCMD To Update Server? yes/no", "UseSteamCMD", "yes")
   Local $steamcmddir = IniRead("ConanServerUtility.ini", "SteamCMD Directory. NO TRAILING SLASH", "steamcmddir", "C:\Game_Servers\SteamCMD")
   Local $UseRemoteRestart = IniRead("ConanServerUtility.ini", "Use Remote Restart ?yes/no", "UseRemoteRestart", "no")
   Local $g_Port = IniRead("ConanServerUtility.ini", "Remote Restart Port", "ListenPort", "57520")
   Local $RestartCode = IniRead("ConanServerUtility.ini", "Remote Restart Password", "RestartCode", "FVtb2DXgp8SYwj7J")
   Local $RestartDaily= IniRead("ConanServerUtility.ini", "Restart Server Daily? yes/no", "RestartDaily", "no")
   Local $HotHour = IniRead("ConanServerUtility.ini", "Daily Restart Hour? 00-23", "HotHour", "00")
   Local $HotMin = IniRead("ConanServerUtility.ini", "Daily Restart Minute? 00-59", "HotMin", "01")
   Local $ExMem = IniRead("ConanServerUtility.ini", "Excessive Memory Amount?", "ExMem", "6000000000")
   Local $ExMemRestart = IniRead("ConanServerUtility.ini", "Restart On Excessive Memory Use? yes/no", "ExMemRestart", "no")
Else
   IniWrite("ConanServerUtility.ini", "Game Server IP", "ListenIP", "127.0.0.1")
   IniWrite("ConanServerUtility.ini", "Game Server Port", "GamePort", "27015")
   IniWrite("ConanServerUtility.ini", "Admin Password", "AdminPass", "yOuRpaSHeRe")
   IniWrite("ConanServerUtility.ini", "Max Players", "MaxPlayers", "20")
   IniWrite("ConanServerUtility.ini", "Server Directory. NO TRAILING SLASH", "serverdir", "C:\Game_Servers\Conan_Exiles_Server")
   IniWrite("ConanServerUtility.ini", "Use SteamCMD To Update Server? yes/no", "UseSteamCMD", "yes")
   IniWrite("ConanServerUtility.ini", "SteamCMD Directory. NO TRAILING SLASH", "steamcmddir", "C:\Game_Servers\SteamCMD")
   IniWrite("ConanServerUtility.ini", "Use Remote Restart ?yes/no", "UseRemoteRestart", "no")
   IniWrite("ConanServerUtility.ini", "Remote Restart Port", "ListenPort", "57520")
   IniWrite("ConanServerUtility.ini", "Remote Restart Password", "RestartCode", "FVtb2DXgp8SYwj7J")
   IniWrite("ConanServerUtility.ini", "Restart Server Daily? yes/no", "RestartDaily", "no")
   IniWrite("ConanServerUtility.ini", "Daily Restart Hour? 00-23", "HotHour", "00")
   IniWrite("ConanServerUtility.ini", "Daily Restart Minute? 00-59", "HotMin", "01")
   IniWrite("ConanServerUtility.ini", "Excessive Memory Amount?", "ExMem", "6000000000")
   IniWrite("ConanServerUtility.ini", "Restart On Excessive Memory Use? yes/no", "ExMemRestart", "no")
   MsgBox(4096, "Default INI File Made", "Please Modify Default Values and Restart Script")
   Exit
EndIf

OnAutoItExitRegister("Gamercide")

Func Gamercide()
	If @exitMethod <> 1 Then
	$Shutdown = MsgBox(4100, "Shut Down?","Do you wish to shutdown the server?",10)
		If $Shutdown = 6 Then
			CloseServer()
		EndIf
		MsgBox(4096, "Thanks for using our Application", "Please visit us at https://gamercide.com",5)
	EndIf
	Exit
EndFunc

Func CloseServer()
   Local $PID = ProcessExists("ConanSandboxServer-Win64-Test.exe")
   ;WinClose("Conan")
	  ControlSend(""& $serverdir &"\ConanSandbox\Binaries\Win64\ConanSandboxServer-Win64-Test.exe", "", "", "^c" & @CR)
	  ControlSend("Conan", "", "", "^c" & @CR)
   sleep(60000)
   	  If $PID Then
		 ProcessClose($PID)
      EndIf
EndFunc

Func _TCP_Server_ClientIP($hSocket)
   Local $pSocketAddress, $aReturn
   $pSocketAddress = DllStructCreate("short;ushort;uint;char[8]")
   $aReturn = DllCall("ws2_32.dll", "int", "getpeername", "int", $hSocket, "ptr", DllStructGetPtr($pSocketAddress), "int*", DllStructGetSize($pSocketAddress))
   If @error Or $aReturn[0] <> 0 Then Return $hSocket
	  $aReturn = DllCall("ws2_32.dll", "str", "inet_ntoa", "int", DllStructGetData($pSocketAddress, 3))
   If @error Then Return $hSocket
	  $pSocketAddress = 0
   Return $aReturn[0]
EndFunc ;==>_TCP_Server_ClientIP

If $UseSteamCMD = "yes" Then
	Local $sFileExists = FileExists($steamcmddir &"\steamcmd.exe")
	If $sFileExists = 0 Then
		MsgBox ( 0x0, "SteamCMD Not Found", "Could not find steamcmd.exe at "& $steamcmddir)
		Exit
	EndIf

Else
	Local $cFileExists = FileExists($serverdir &"\ConanSandboxServer.exe")
	If $cFileExists = 0 Then
		MsgBox ( 0x0, "Conan Server Not Found", "Could not find ConanSandboxServer.exe at "& $serverdir)
		Exit
	EndIf
Endif


If $UseRemoteRestart = "yes" Then
; Start The TCP Services
TCPStartup()
Local $MainSocket = TCPListen($g_IP, $g_Port, 100)
	If $MainSocket = -1 Then
		MsgBox ( 0x0, "TCP Error", "Could not bind to [" &  $g_IP & "] Is this the correct Server IP?")
		Exit
		EndIf
EndIf

While True
If $UseRemoteRestart = "yes" Then
Local $ConnectedSocket = TCPAccept($MainSocket)
If $ConnectedSocket >= 0 Then
;TrayTip("Connected","Someone connected to server.",3)
$Count = 0
While $Count < 30
$RECV = TCPRecv($ConnectedSocket,512)
   If $RECV = $RestartCode Then
	  Local $PID = ProcessExists("ConanSandboxServer-Win64-Test.exe") ; Will return the PID or 0 if the process isn't found.
	  If $PID Then
		 $IP = _TCP_Server_ClientIP($ConnectedSocket)
		 Local $MEM = ProcessGetStats($PID, 0)
		 FileWriteLine(@ScriptDir & "\ConanServerUtility_RestartLog.txt", @MON &"-"& @MDAY &"-"& @YEAR &" "& @HOUR &":"& @MIN &" --Work Memory:"& $MEM[0] & _
		 " --Peak Memory:"& $MEM[1] &" Restart Requested by Remote Host: "& $IP)
		 ;ProcessClose($PID)
		 CloseServer()
		 Sleep (10000)
		 ExitLoop
	  EndIf
   Else
		 FileWriteLine(@ScriptDir & "\ConanServerUtility_RestartLog.txt", @MON &"-"& @MDAY &"-"& @YEAR &" "& @HOUR &":"& @MIN &" Restart ATTEMPT by Remote Host: "& $IP &"WRONG PASSWORD")
		 ExitLoop
   EndIf
$Count += 1
Sleep (1000)
WEnd
If $ConnectedSocket <> -1 Then TCPCloseSocket($ConnectedSocket)
EndIf
EndIf


Local $PID = ProcessExists("ConanSandboxServer-Win64-Test.exe")
If $PID = 0 Then
	If $UseSteamCMD = "yes" Then
		RunWait(""& $steamcmddir &"\steamcmd.exe +@ShutdownOnFailedCommand 1 +@NoPromptForPassword 1 +login anonymous +force_install_dir "& $serverdir &" +app_update 443030 validate +quit")
	EndIf
	Run(""& $serverdir &"\ConanSandbox\Binaries\Win64\ConanSandboxServer-Win64-Test.exe ConanSandBox?MULTIHOME="& $g_IP &"?QueryPort="& $GamePort &"?MaxPlayers="& $MaxPlayers &"?AdminPassword="& $AdminPass &"?listen -nosteamclient -game -server -log")
	Sleep (70000)
Else
   Local $MEM = ProcessGetStats($PID, 0)
   If $MEM[0] > $ExMem And $ExMemRestart = "no" Then
	  FileWriteLine(@ScriptDir & "\ConanServerUtility_ExcessiveMemoryLog.txt", @MON &"-"& @MDAY &"-"& @YEAR &" "& @HOUR &":"& @MIN &" --Work Memory:"& $MEM[0] & _
        " --Peak Memory:"& $MEM[1])
	  Sleep (10000)
   ElseIf $MEM[0] > $ExMem And $ExMemRestart = "yes" Then
	  FileWriteLine(@ScriptDir & "\ConanServerUtility_RestartLog.txt", @MON &"-"& @MDAY &"-"& @YEAR &" "& @HOUR &":"& @MIN &" --Work Memory:"& $MEM[0] & _
	  " --Peak Memory:"& $MEM[1] &" Excessive Memory Use - Restart Requested by ConanServerUtility Script")
	  ;ProcessClose($PID)
	  CloseServer()
	  Sleep (10000)
   EndIf
EndIf

If @HOUR = $HotHour And @MIN = $HotMin And $RestartDaily = "yes" Then
   Local $PID = ProcessExists("ConanSandboxServer-Win64-Test.exe")
	  If $PID Then
		 Local $MEM = ProcessGetStats($PID, 0)
		 FileWriteLine(@ScriptDir & "\ConanServerUtility_RestartLog.txt", @MON &"-"& @MDAY &"-"& @YEAR &" "& @HOUR &":"& @MIN &" --Work Memory:"& $MEM[0] & _
		 " --Peak Memory:"& $MEM[1] &" Daily Restart Requested by ConanServerUtility Script")
		 ;ProcessClose($PID)
		 CloseServer()
	  EndIf
   Sleep (10000)
EndIf

Sleep (500)
WEnd

 

 

Remote Restart Utility V2.0 Source

Spoiler

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=favicon.ico
#AutoIt3Wrapper_Res_Comment=By Dateranoth - Feburary 4, 2017
#AutoIt3Wrapper_Res_Description=Utility to Remotely Restart Conan Server
#AutoIt3Wrapper_Res_Fileversion=2.0
#AutoIt3Wrapper_Res_LegalCopyright=Dateranoth @ https://gamercide.org
#AutoIt3Wrapper_Res_Language=1033
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
;By Dateranoth - Feburary 4, 2017
;Used by https://gamercide.com on their server
;Feel free to change, adapt, and distribute
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
; Start The TCP Services
    ;==============================================
    TCPStartup()

   ; Set Some reusable info
   ;--------------------------
   Local $ConnectedSocket, $szData
If FileExists("ConanServerRemoteRestart.ini") Then
   Local $cIPADDRESS = IniRead("ConanServerRemoteRestart.ini", "GameServerIP", "cIPADDRESS", "127.0.0.1")
   Local $cPORT = IniRead("ConanServerRemoteRestart.ini", "RestartServerPort", "cPORT", "57520")
   Local $RPassword = IniRead("ConanServerRemoteRestart.ini", "DefaultRestartPassword", "RPassword", "")

Else
   IniWrite("ConanServerRemoteRestart.ini", "GameServerIP", "cIPADDRESS", "127.0.0.1")
   IniWrite("ConanServerRemoteRestart.ini", "RestartServerPort", "cPORT", "57520")
   IniWrite("ConanServerRemoteRestart.ini", "DefaultRestartPassword", "RPassword", "")
   MsgBox(4096, "Default INI File Made", "Please Modify Default Values and Restart Script")
   Exit
EndIf

OnAutoItExitRegister("Gamercide")
Func Gamercide()
	MsgBox(4096, "Thanks for using our Application", "Please visit us at https://gamercide.com",5)
	Exit
EndFunc

Func MyTCP_Client($sIPAddress, $iPort, $iData)
    ; Assign a Local variable the socket and connect to a listening socket with the IP Address and Port specified.
    Local $iSocket = TCPConnect($sIPAddress, $iPort)
    Local $iError = 0
    Local $cData = StringToBinary($iData, 4)

    ; If an error occurred display the error code and return False.
    If @error Then
        ; The server is probably offline/port is not opened on the server.
        $iError = @error
        MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", "Client:" & @CRLF & "Could not connect, Error code: " & $iError)
        Return False
    EndIf

    ; Send Restart Code to the Server.
    TCPSend($iSocket, $cData)

    ; If an error occurred display the error code and return False.
    If @error Then
        $iError = @error
        MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", "Client:" & @CRLF & "Could not send the data, Error code: " & $iError)
        Return False
    EndIf

    ; Close the socket.
    TCPCloseSocket($iSocket)
EndFunc   ;==>MyTCP_Client

        ;Loop forever asking for data to send to the SERVER
        While 1
            ; InputBox for data to transmit
            $cPass = InputBox("Restart The Conan Server", @LF & @LF & "Enter the code to Restart The Conan Server within 30 seconds:",$RPassword)

            ; If they cancel the InputBox or leave it blank we exit our forever loop
            If @error Or $cPass = "" Then
			   MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", "No Restart Sent",5)
			   ExitLoop
			Else
			   MyTCP_Client($cIPAddress, $cPort, $cPass)
			   ExitLoop
			EndIf
        WEnd

TCPShutdown()

 

Share this post


Link to post
Share on other sites

V2.1 Update!

Bug Fix release. Missed a variable declaration when wrong restart code was sent. This corrects that issue. Restart Utility was not changed, but I will be updating revision anyway.

 

 

V2.1 Downloads

Complete Version 2.1 including Source

Conan Server Utility V2.1

Conan Server Remote Restart Utility V2.1

Conan Server Utility V2.1 Source

Conan Server Remote Restart Utility V2.1 Source

 

V2.1 Source:

Spoiler

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=favicon.ico
#AutoIt3Wrapper_Res_Comment=By Dateranoth - Feburary 4, 2017
#AutoIt3Wrapper_Res_Description=Utility for Running Conan Server
#AutoIt3Wrapper_Res_Fileversion=2.1.0.0
#AutoIt3Wrapper_Res_LegalCopyright=Dateranoth @ https://gamercide.org
#AutoIt3Wrapper_Res_Language=1033
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
;By Dateranoth - Feburary 4, 2017
;Used by https://gamercide.com on their server
;Feel free to change, adapt, and distribute

#include <Date.au3>
#include <Process.au3>
#include <MsgBoxConstants.au3>
Opt("WinTitleMatchMode", -2) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase

;User Variables
If FileExists("ConanServerUtility.ini") Then
   Local $g_IP = IniRead("ConanServerUtility.ini", "Game Server IP", "ListenIP", "127.0.0.1")
   Local $GamePort = IniRead("ConanServerUtility.ini", "Game Server Port", "GamePort", "27015")
   Local $AdminPass = IniRead("ConanServerUtility.ini", "Admin Password", "AdminPass", "yOuRpaSHeRe")
   Local $MaxPlayers = IniRead("ConanServerUtility.ini", "Max Players", "MaxPlayers", "20")
   Local $serverdir = IniRead("ConanServerUtility.ini", "Server Directory. NO TRAILING SLASH", "serverdir", "C:\Game_Servers\Conan_Exiles_Server")
   Local $UseSteamCMD = IniRead("ConanServerUtility.ini", "Use SteamCMD To Update Server? yes/no", "UseSteamCMD", "yes")
   Local $steamcmddir = IniRead("ConanServerUtility.ini", "SteamCMD Directory. NO TRAILING SLASH", "steamcmddir", "C:\Game_Servers\SteamCMD")
   Local $UseRemoteRestart = IniRead("ConanServerUtility.ini", "Use Remote Restart ?yes/no", "UseRemoteRestart", "no")
   Local $g_Port = IniRead("ConanServerUtility.ini", "Remote Restart Port", "ListenPort", "57520")
   Local $RestartCode = IniRead("ConanServerUtility.ini", "Remote Restart Password", "RestartCode", "FVtb2DXgp8SYwj7J")
   Local $RestartDaily= IniRead("ConanServerUtility.ini", "Restart Server Daily? yes/no", "RestartDaily", "no")
   Local $HotHour = IniRead("ConanServerUtility.ini", "Daily Restart Hour? 00-23", "HotHour", "00")
   Local $HotMin = IniRead("ConanServerUtility.ini", "Daily Restart Minute? 00-59", "HotMin", "01")
   Local $ExMem = IniRead("ConanServerUtility.ini", "Excessive Memory Amount?", "ExMem", "6000000000")
   Local $ExMemRestart = IniRead("ConanServerUtility.ini", "Restart On Excessive Memory Use? yes/no", "ExMemRestart", "no")
Else
   IniWrite("ConanServerUtility.ini", "Game Server IP", "ListenIP", "127.0.0.1")
   IniWrite("ConanServerUtility.ini", "Game Server Port", "GamePort", "27015")
   IniWrite("ConanServerUtility.ini", "Admin Password", "AdminPass", "yOuRpaSHeRe")
   IniWrite("ConanServerUtility.ini", "Max Players", "MaxPlayers", "20")
   IniWrite("ConanServerUtility.ini", "Server Directory. NO TRAILING SLASH", "serverdir", "C:\Game_Servers\Conan_Exiles_Server")
   IniWrite("ConanServerUtility.ini", "Use SteamCMD To Update Server? yes/no", "UseSteamCMD", "yes")
   IniWrite("ConanServerUtility.ini", "SteamCMD Directory. NO TRAILING SLASH", "steamcmddir", "C:\Game_Servers\SteamCMD")
   IniWrite("ConanServerUtility.ini", "Use Remote Restart ?yes/no", "UseRemoteRestart", "no")
   IniWrite("ConanServerUtility.ini", "Remote Restart Port", "ListenPort", "57520")
   IniWrite("ConanServerUtility.ini", "Remote Restart Password", "RestartCode", "FVtb2DXgp8SYwj7J")
   IniWrite("ConanServerUtility.ini", "Restart Server Daily? yes/no", "RestartDaily", "no")
   IniWrite("ConanServerUtility.ini", "Daily Restart Hour? 00-23", "HotHour", "00")
   IniWrite("ConanServerUtility.ini", "Daily Restart Minute? 00-59", "HotMin", "01")
   IniWrite("ConanServerUtility.ini", "Excessive Memory Amount?", "ExMem", "6000000000")
   IniWrite("ConanServerUtility.ini", "Restart On Excessive Memory Use? yes/no", "ExMemRestart", "no")
   MsgBox(4096, "Default INI File Made", "Please Modify Default Values and Restart Script")
   Exit
EndIf

OnAutoItExitRegister("Gamercide")

Func Gamercide()
	If @exitMethod <> 1 Then
	$Shutdown = MsgBox(4100, "Shut Down?","Do you wish to shutdown the server?",10)
		If $Shutdown = 6 Then
			CloseServer()
		EndIf
		MsgBox(4096, "Thanks for using our Application", "Please visit us at https://gamercide.com",5)
	EndIf
	Exit
EndFunc

Func CloseServer()
   Local $PID = ProcessExists("ConanSandboxServer-Win64-Test.exe")
   ;WinClose("Conan")
	  ControlSend(""& $serverdir &"\ConanSandbox\Binaries\Win64\ConanSandboxServer-Win64-Test.exe", "", "", "^c" & @CR)
	  ControlSend("Conan", "", "", "^c" & @CR)
   sleep(60000)
   	  If $PID Then
		 ProcessClose($PID)
      EndIf
EndFunc

Func _TCP_Server_ClientIP($hSocket)
   Local $pSocketAddress, $aReturn
   $pSocketAddress = DllStructCreate("short;ushort;uint;char[8]")
   $aReturn = DllCall("ws2_32.dll", "int", "getpeername", "int", $hSocket, "ptr", DllStructGetPtr($pSocketAddress), "int*", DllStructGetSize($pSocketAddress))
   If @error Or $aReturn[0] <> 0 Then Return $hSocket
	  $aReturn = DllCall("ws2_32.dll", "str", "inet_ntoa", "int", DllStructGetData($pSocketAddress, 3))
   If @error Then Return $hSocket
	  $pSocketAddress = 0
   Return $aReturn[0]
EndFunc ;==>_TCP_Server_ClientIP

If $UseSteamCMD = "yes" Then
	Local $sFileExists = FileExists($steamcmddir &"\steamcmd.exe")
	If $sFileExists = 0 Then
		MsgBox ( 0x0, "SteamCMD Not Found", "Could not find steamcmd.exe at "& $steamcmddir)
		Exit
	EndIf

Else
	Local $cFileExists = FileExists($serverdir &"\ConanSandboxServer.exe")
	If $cFileExists = 0 Then
		MsgBox ( 0x0, "Conan Server Not Found", "Could not find ConanSandboxServer.exe at "& $serverdir)
		Exit
	EndIf
Endif


If $UseRemoteRestart = "yes" Then
; Start The TCP Services
TCPStartup()
Local $MainSocket = TCPListen($g_IP, $g_Port, 100)
	If $MainSocket = -1 Then
		MsgBox ( 0x0, "TCP Error", "Could not bind to [" &  $g_IP & "] Is this the correct Server IP?")
		Exit
		EndIf
EndIf

While True
If $UseRemoteRestart = "yes" Then
Local $ConnectedSocket = TCPAccept($MainSocket)
If $ConnectedSocket >= 0 Then
;TrayTip("Connected","Someone connected to server.",3)
$Count = 0
While $Count < 30
$RECV = TCPRecv($ConnectedSocket,512)
   If $RECV = $RestartCode Then
	  Local $PID = ProcessExists("ConanSandboxServer-Win64-Test.exe") ; Will return the PID or 0 if the process isn't found.
	  If $PID Then
		 $IP = _TCP_Server_ClientIP($ConnectedSocket)
		 Local $MEM = ProcessGetStats($PID, 0)
		 FileWriteLine(@ScriptDir & "\ConanServerUtility_RestartLog.txt", @MON &"-"& @MDAY &"-"& @YEAR &" "& @HOUR &":"& @MIN &" --Work Memory:"& $MEM[0] & _
		 " --Peak Memory:"& $MEM[1] &" Restart Requested by Remote Host: "& $IP)
		 ;ProcessClose($PID)
		 CloseServer()
		 Sleep (10000)
		 ExitLoop
	  EndIf
	  Else
		$IP = _TCP_Server_ClientIP($ConnectedSocket)
		FileWriteLine(@ScriptDir & "\ConanServerUtility_RestartLog.txt", @MON &"-"& @MDAY &"-"& @YEAR &" "& @HOUR &":"& @MIN &" Restart ATTEMPT by Remote Host: "& $IP &" WRONG PASSWORD")
		ExitLoop
   EndIf
$Count += 1
Sleep (1000)
WEnd
If $ConnectedSocket <> -1 Then TCPCloseSocket($ConnectedSocket)
EndIf
EndIf


Local $PID = ProcessExists("ConanSandboxServer-Win64-Test.exe")
If $PID = 0 Then
	If $UseSteamCMD = "yes" Then
		RunWait(""& $steamcmddir &"\steamcmd.exe +@ShutdownOnFailedCommand 1 +@NoPromptForPassword 1 +login anonymous +force_install_dir "& $serverdir &" +app_update 443030 validate +quit")
	EndIf
	Run(""& $serverdir &"\ConanSandbox\Binaries\Win64\ConanSandboxServer-Win64-Test.exe ConanSandBox?MULTIHOME="& $g_IP &"?QueryPort="& $GamePort &"?MaxPlayers="& $MaxPlayers &"?AdminPassword="& $AdminPass &"?listen -nosteamclient -game -server -log")
	Sleep (70000)
Else
   Local $MEM = ProcessGetStats($PID, 0)
   If $MEM[0] > $ExMem And $ExMemRestart = "no" Then
	  FileWriteLine(@ScriptDir & "\ConanServerUtility_ExcessiveMemoryLog.txt", @MON &"-"& @MDAY &"-"& @YEAR &" "& @HOUR &":"& @MIN &" --Work Memory:"& $MEM[0] & _
        " --Peak Memory:"& $MEM[1])
	  Sleep (10000)
   ElseIf $MEM[0] > $ExMem And $ExMemRestart = "yes" Then
	  FileWriteLine(@ScriptDir & "\ConanServerUtility_RestartLog.txt", @MON &"-"& @MDAY &"-"& @YEAR &" "& @HOUR &":"& @MIN &" --Work Memory:"& $MEM[0] & _
	  " --Peak Memory:"& $MEM[1] &" Excessive Memory Use - Restart Requested by ConanServerUtility Script")
	  ;ProcessClose($PID)
	  CloseServer()
	  Sleep (10000)
   EndIf
EndIf

If @HOUR = $HotHour And @MIN = $HotMin And $RestartDaily = "yes" Then
   Local $PID = ProcessExists("ConanSandboxServer-Win64-Test.exe")
	  If $PID Then
		 Local $MEM = ProcessGetStats($PID, 0)
		 FileWriteLine(@ScriptDir & "\ConanServerUtility_RestartLog.txt", @MON &"-"& @MDAY &"-"& @YEAR &" "& @HOUR &":"& @MIN &" --Work Memory:"& $MEM[0] & _
		 " --Peak Memory:"& $MEM[1] &" Daily Restart Requested by ConanServerUtility Script")
		 ;ProcessClose($PID)
		 CloseServer()
	  EndIf
   Sleep (10000)
EndIf

Sleep (500)
WEnd

 

Share this post


Link to post
Share on other sites

" You can also use  SteamCMD and remote restart to update the server anytime you send the restart request. "

When your server needs an update, force a restart with the utility and your server should look for an update and download it.

Share this post


Link to post
Share on other sites

@verser

I just added the automatic Update Feature

V2.2 Update!

Added the ability to turn on update checks. If you enable this feature, the script will parse the dev RSS feed for PATCH titles. If a new one is found it will automatically restart the server to apply the update. You need to have SteamCMD enabled for this to work properly. Also corrected some bugs.

V2.2 Downloads

Complete Version 2.2 including Source

Conan Server Utility V2.2

Conan Server Remote Restart Utility V2.2

Conan Server Utility V2.2 Source

Conan Server Remote Restart Utility V2.2 Source

 

V2.2 Conan Server Utility Source

Spoiler

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=favicon.ico
#AutoIt3Wrapper_Res_Comment=By Dateranoth - Feburary 5, 2017
#AutoIt3Wrapper_Res_Description=Utility for Running Conan Server
#AutoIt3Wrapper_Res_Fileversion=2.2.0.0
#AutoIt3Wrapper_Res_LegalCopyright=Dateranoth @ https://gamercide.com
#AutoIt3Wrapper_Res_Language=1033
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
;By Dateranoth - Feburary 4, 2017
;Used by https://gamercide.com on their server
;Feel free to change, adapt, and distribute

#include <Date.au3>
#include <Process.au3>
#include <MsgBoxConstants.au3>
#include <File.au3>
Opt("WinTitleMatchMode", 1) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase

;User Variables
If FileExists("ConanServerUtility.ini") Then
   Local $g_IP = IniRead("ConanServerUtility.ini", "Game Server IP", "ListenIP", "127.0.0.1")
   Local $GamePort = IniRead("ConanServerUtility.ini", "Game Server Port", "GamePort", "27015")
   Local $AdminPass = IniRead("ConanServerUtility.ini", "Admin Password", "AdminPass", "yOuRpaSHeRe")
   Local $MaxPlayers = IniRead("ConanServerUtility.ini", "Max Players", "MaxPlayers", "20")
   Local $serverdir = IniRead("ConanServerUtility.ini", "Server Directory. NO TRAILING SLASH", "serverdir", "C:\Game_Servers\Conan_Exiles_Server")
   Local $UseSteamCMD = IniRead("ConanServerUtility.ini", "Use SteamCMD To Update Server? yes/no", "UseSteamCMD", "yes")
   Local $steamcmddir = IniRead("ConanServerUtility.ini", "SteamCMD Directory. NO TRAILING SLASH", "steamcmddir", "C:\Game_Servers\SteamCMD")
   Local $UseRemoteRestart = IniRead("ConanServerUtility.ini", "Use Remote Restart ?yes/no", "UseRemoteRestart", "no")
   Local $g_Port = IniRead("ConanServerUtility.ini", "Remote Restart Port", "ListenPort", "57520")
   Local $RestartCode = IniRead("ConanServerUtility.ini", "Remote Restart Password", "RestartCode", "FVtb2DXgp8SYwj7J")
   Local $RestartDaily = IniRead("ConanServerUtility.ini", "Restart Server Daily? yes/no", "RestartDaily", "no")
   Local $CheckForUpdate = IniRead("ConanServerUtility.ini", "Check for Update Every Hour? yes/no", "CheckForUpdate", "yes")
   Local $HotHour = IniRead("ConanServerUtility.ini", "Daily Restart Hour? 00-23", "HotHour", "00")
   Local $HotMin = IniRead("ConanServerUtility.ini", "Daily Restart Minute? 00-59", "HotMin", "01")
   Local $ExMem = IniRead("ConanServerUtility.ini", "Excessive Memory Amount?", "ExMem", "6000000000")
   Local $ExMemRestart = IniRead("ConanServerUtility.ini", "Restart On Excessive Memory Use? yes/no", "ExMemRestart", "no")
Else
   IniWrite("ConanServerUtility.ini", "Game Server IP", "ListenIP", "127.0.0.1")
   IniWrite("ConanServerUtility.ini", "Game Server Port", "GamePort", "27015")
   IniWrite("ConanServerUtility.ini", "Admin Password", "AdminPass", "yOuRpaSHeRe")
   IniWrite("ConanServerUtility.ini", "Max Players", "MaxPlayers", "20")
   IniWrite("ConanServerUtility.ini", "Server Directory. NO TRAILING SLASH", "serverdir", "C:\Game_Servers\Conan_Exiles_Server")
   IniWrite("ConanServerUtility.ini", "Use SteamCMD To Update Server? yes/no", "UseSteamCMD", "yes")
   IniWrite("ConanServerUtility.ini", "SteamCMD Directory. NO TRAILING SLASH", "steamcmddir", "C:\Game_Servers\SteamCMD")
   IniWrite("ConanServerUtility.ini", "Use Remote Restart ?yes/no", "UseRemoteRestart", "no")
   IniWrite("ConanServerUtility.ini", "Remote Restart Port", "ListenPort", "57520")
   IniWrite("ConanServerUtility.ini", "Remote Restart Password", "RestartCode", "FVtb2DXgp8SYwj7J")
   IniWrite("ConanServerUtility.ini", "Restart Server Daily? yes/no", "RestartDaily", "no")
   IniWrite("ConanServerUtility.ini", "Check for Update Every Hour? yes/no", "CheckForUpdate", "yes")
   IniWrite("ConanServerUtility.ini", "Daily Restart Hour? 00-23", "HotHour", "00")
   IniWrite("ConanServerUtility.ini", "Daily Restart Minute? 00-59", "HotMin", "01")
   IniWrite("ConanServerUtility.ini", "Excessive Memory Amount?", "ExMem", "6000000000")
   IniWrite("ConanServerUtility.ini", "Restart On Excessive Memory Use? yes/no", "ExMemRestart", "no")
   MsgBox(4096, "Default INI File Made", "Please Modify Default Values and Restart Script")
   Exit
EndIf

OnAutoItExitRegister("Gamercide")

Func Gamercide()
	If @exitMethod <> 1 Then
	$Shutdown = MsgBox(4100, "Shut Down?","Do you wish to shutdown the server?",10)
		If $Shutdown = 6 Then
			CloseServer()
		EndIf
		MsgBox(4096, "Thanks for using our Application", "Please visit us at https://gamercide.com",5)
	EndIf
	Exit
EndFunc

Func CloseServer()
	Local $PID = ProcessExists("ConanSandboxServer-Win64-Test.exe")
	ControlSend("Conan Exiles -", "", "", "I" & @CR)
	ControlSend("Conan Exiles -", "", "", "I" & @CR)
	ControlSend("Conan Exiles -", "", "", "^C")
	WinWaitClose("Conan Exiles -", "", 60)
	If $PID Then
		ProcessClose($PID)
    EndIf
EndFunc

Func UpdateCheck()
	Local $oXML = ObjCreate("Microsoft.XMLHTTP")
	$oXML.Open("GET", "http://steamcommunity.com/games/440900/rss/", 0)
	$oXML.Send

	Global $sFile = _TempFile(@ScriptDir, '~', '.xml')
	FileWrite($sFile, $oXML.responseText)

	$sXML = $sFile
	Local $oXML = ObjCreate("Microsoft.XMLDOM")
	$oXML.Load($sXML)
	Local $oNames = $oXML.selectNodes("//rss/channel/item/title")
	Local $aMyDate, $aMyTime
	_DateTimeSplit(_NowCalc(), $aMyDate, $aMyTime)
    Local $cDate = "PATCH "& StringFormat("%02d", $aMyDate[2]) &"."& StringFormat("%02d", $aMyDate[3]) &"."& StringFormat("%04d", $aMyDate[1])
	Local $cFile = @ScriptDir &"/ConanServerUtility_LastUpdate.txt"

	For $oName In $oNames

		If StringRegExp($oName.text,$cDate&"(?i)") Then
				If FileRead(FileOpen($cFile)) = $oName.text Then
					;ConsoleWrite("No New Update" & @CRLF)
					FileClose($cFile)
					ExitLoop
				Else
					FileClose($cFile)
					FileWrite(FileOpen($cFile,2),$oName.text)
					ConsoleWrite($oName.text & @CRLF)
					FileClose($cFile)
					Local $PID = ProcessExists("ConanSandboxServer-Win64-Test.exe")
					If $PID Then
						FileWriteLine(@ScriptDir & "\ConanServerUtility_RestartLog.txt", @MON &"-"& @MDAY &"-"& @YEAR &" "& @HOUR &":"& @MIN &"["& $oName.txt &"] Restart Requested by ConanServerUtility Script")
						CloseServer()
					EndIf
					ExitLoop
				EndIf
		EndIf
	Next
	FileDelete($sFile)
EndFunc

Func _TCP_Server_ClientIP($hSocket)
   Local $pSocketAddress, $aReturn
   $pSocketAddress = DllStructCreate("short;ushort;uint;char[8]")
   $aReturn = DllCall("ws2_32.dll", "int", "getpeername", "int", $hSocket, "ptr", DllStructGetPtr($pSocketAddress), "int*", DllStructGetSize($pSocketAddress))
   If @error Or $aReturn[0] <> 0 Then Return $hSocket
	  $aReturn = DllCall("ws2_32.dll", "str", "inet_ntoa", "int", DllStructGetData($pSocketAddress, 3))
   If @error Then Return $hSocket
	  $pSocketAddress = 0
   Return $aReturn[0]
EndFunc ;==>_TCP_Server_ClientIP

If $UseSteamCMD = "yes" Then
	Local $sFileExists = FileExists($steamcmddir &"\steamcmd.exe")
	If $sFileExists = 0 Then
		MsgBox ( 0x0, "SteamCMD Not Found", "Could not find steamcmd.exe at "& $steamcmddir)
		Exit
	EndIf

Else
	Local $cFileExists = FileExists($serverdir &"\ConanSandboxServer.exe")
	If $cFileExists = 0 Then
		MsgBox ( 0x0, "Conan Server Not Found", "Could not find ConanSandboxServer.exe at "& $serverdir)
		Exit
	EndIf
Endif


If $UseRemoteRestart = "yes" Then
; Start The TCP Services
TCPStartup()
Local $MainSocket = TCPListen($g_IP, $g_Port, 100)
	If $MainSocket = -1 Then
		MsgBox ( 0x0, "TCP Error", "Could not bind to [" &  $g_IP & "] Is this the correct Server IP?")
		Exit
		EndIf
EndIf

While True
If $UseRemoteRestart = "yes" Then
Local $ConnectedSocket = TCPAccept($MainSocket)
If $ConnectedSocket >= 0 Then
$Count = 0
While $Count < 30
$RECV = TCPRecv($ConnectedSocket,512)
   If $RECV = $RestartCode Then
	  Local $PID = ProcessExists("ConanSandboxServer-Win64-Test.exe") ; Will return the PID or 0 if the process isn't found.
	  Local $IP = _TCP_Server_ClientIP($ConnectedSocket)
	  If $PID Then
		 Local $MEM = ProcessGetStats($PID, 0)
		 FileWriteLine(@ScriptDir & "\ConanServerUtility_RestartLog.txt", @MON &"-"& @MDAY &"-"& @YEAR &" "& @HOUR &":"& @MIN &" --Work Memory:"& $MEM[0] & _
		 " --Peak Memory:"& $MEM[1] &" Restart Requested by Remote Host: "& $IP)
		 CloseServer()
		 Sleep (10000)
		 ExitLoop
	  EndIf
	  Else
		FileWriteLine(@ScriptDir & "\ConanServerUtility_RestartLog.txt", @MON &"-"& @MDAY &"-"& @YEAR &" "& @HOUR &":"& @MIN &" Restart ATTEMPT by Remote Host: "& $IP &" WRONG PASSWORD")
		ExitLoop
   EndIf
$Count += 1
Sleep (1000)
WEnd
If $ConnectedSocket <> -1 Then TCPCloseSocket($ConnectedSocket)
EndIf
EndIf


Local $PID = ProcessExists("ConanSandboxServer-Win64-Test.exe")
If $PID = 0 Then
	If $UseSteamCMD = "yes" Then
		RunWait(""& $steamcmddir &"\steamcmd.exe +@ShutdownOnFailedCommand 1 +@NoPromptForPassword 1 +login anonymous +force_install_dir "& $serverdir &" +app_update 443030 validate +quit")
	EndIf
	If $CheckForUpdate = "yes" Then
		UpdateCheck()
	EndIf
	Run(""& $serverdir &"\ConanSandbox\Binaries\Win64\ConanSandboxServer-Win64-Test.exe ConanSandBox?MULTIHOME="& $g_IP &"?QueryPort="& $GamePort &"?MaxPlayers="& $MaxPlayers &"?AdminPassword="& $AdminPass &"?listen -nosteamclient -game -server -log")
	WinWait("Conan Exiles -", "", 70)
Else
   Local $MEM = ProcessGetStats($PID, 0)
   If $MEM[0] > $ExMem And $ExMemRestart = "no" Then
	  FileWriteLine(@ScriptDir & "\ConanServerUtility_ExcessiveMemoryLog.txt", @MON &"-"& @MDAY &"-"& @YEAR &" "& @HOUR &":"& @MIN &" --Work Memory:"& $MEM[0] & _
        " --Peak Memory:"& $MEM[1])
	  Sleep (10000)
   ElseIf $MEM[0] > $ExMem And $ExMemRestart = "yes" Then
	  FileWriteLine(@ScriptDir & "\ConanServerUtility_RestartLog.txt", @MON &"-"& @MDAY &"-"& @YEAR &" "& @HOUR &":"& @MIN &" --Work Memory:"& $MEM[0] & _
	  " --Peak Memory:"& $MEM[1] &" Excessive Memory Use - Restart Requested by ConanServerUtility Script")
	  CloseServer()
	  Sleep (10000)
   EndIf
EndIf

If @HOUR = $HotHour And @MIN = $HotMin And $RestartDaily = "yes" Then
   Local $PID = ProcessExists("ConanSandboxServer-Win64-Test.exe")
	  If $PID Then
		 Local $MEM = ProcessGetStats($PID, 0)
		 FileWriteLine(@ScriptDir & "\ConanServerUtility_RestartLog.txt", @MON &"-"& @MDAY &"-"& @YEAR &" "& @HOUR &":"& @MIN &" --Work Memory:"& $MEM[0] & _
		 " --Peak Memory:"& $MEM[1] &" Daily Restart Requested by ConanServerUtility Script")
		 CloseServer()
	  EndIf
   Sleep (10000)
EndIf

If @MIN = $HotMin And $CheckForUpdate = "yes" Then
	UpdateCheck()
	Sleep(70000)
EndIf

Sleep (500)
WEnd

 

 

V2.2 Conan Remote Restart Utility Source

 

Spoiler

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=favicon.ico
#AutoIt3Wrapper_Res_Comment=By Dateranoth - Feburary 5, 2017
#AutoIt3Wrapper_Res_Description=Utility to Remotely Restart Conan Server
#AutoIt3Wrapper_Res_Fileversion=2.2
#AutoIt3Wrapper_Res_LegalCopyright=Dateranoth @ https://gamercide.com
#AutoIt3Wrapper_Res_Language=1033
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
;By Dateranoth - Feburary 4, 2017
;Used by https://gamercide.com on their server
;Feel free to change, adapt, and distribute
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
; Start The TCP Services
    ;==============================================
    TCPStartup()

   ; Set Some reusable info
   ;--------------------------
   Local $ConnectedSocket, $szData
If FileExists("ConanServerRemoteRestart.ini") Then
   Local $cIPADDRESS = IniRead("ConanServerRemoteRestart.ini", "GameServerIP", "cIPADDRESS", "127.0.0.1")
   Local $cPORT = IniRead("ConanServerRemoteRestart.ini", "RestartServerPort", "cPORT", "57520")
   Local $RPassword = IniRead("ConanServerRemoteRestart.ini", "DefaultRestartPassword", "RPassword", "")

Else
   IniWrite("ConanServerRemoteRestart.ini", "GameServerIP", "cIPADDRESS", "127.0.0.1")
   IniWrite("ConanServerRemoteRestart.ini", "RestartServerPort", "cPORT", "57520")
   IniWrite("ConanServerRemoteRestart.ini", "DefaultRestartPassword", "RPassword", "")
   MsgBox(4096, "Default INI File Made", "Please Modify Default Values and Restart Script")
   Exit
EndIf

OnAutoItExitRegister("Gamercide")
Func Gamercide()
	MsgBox(4096, "Thanks for using our Application", "Please visit us at https://gamercide.com",5)
	Exit
EndFunc

Func MyTCP_Client($sIPAddress, $iPort, $iData)
    ; Assign a Local variable the socket and connect to a listening socket with the IP Address and Port specified.
    Local $iSocket = TCPConnect($sIPAddress, $iPort)
    Local $iError = 0
    Local $cData = StringToBinary($iData, 4)

    ; If an error occurred display the error code and return False.
    If @error Then
        ; The server is probably offline/port is not opened on the server.
        $iError = @error
        MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", "Client:" & @CRLF & "Could not connect, Error code: " & $iError)
        Return False
    EndIf

    ; Send Restart Code to the Server.
    TCPSend($iSocket, $cData)

    ; If an error occurred display the error code and return False.
    If @error Then
        $iError = @error
        MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", "Client:" & @CRLF & "Could not send the data, Error code: " & $iError)
        Return False
    EndIf

    ; Close the socket.
    TCPCloseSocket($iSocket)
EndFunc   ;==>MyTCP_Client

        ;Loop forever asking for data to send to the SERVER
        While 1
            ; InputBox for data to transmit
            $cPass = InputBox("Restart The Conan Server", @LF & @LF & "Enter the code to Restart The Conan Server within 30 seconds:",$RPassword)

            ; If they cancel the InputBox or leave it blank we exit our forever loop
            If @error Or $cPass = "" Then
			   MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", "No Restart Sent",5)
			   ExitLoop
			Else
			   MyTCP_Client($cIPAddress, $cPort, $cPass)
			   ExitLoop
			EndIf
        WEnd

TCPShutdown()

 

 

Share this post


Link to post
Share on other sites

V2.2.0.1 Update!

Had a request to allow multiple restarts through the day. This makes that possible. There are 4 hour options available now. If you turn on daily restarts and set them all to the same hour it will restart once a day. If you set them to different hours it will restart at each hour.

V2.2.0.1 Downloads

Complete Version 2.2.0.1 including Source

Conan Server Utility V2.2.0.1

Conan Server Remote Restart Utility V2.2.0.1

Conan Server Utility V2.2.0.1 Source

Conan Server Remote Restart Utility V2.2.0.1 Source

 

V2.2.0.1 Server Utility Source:

Spoiler

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=favicon.ico
#AutoIt3Wrapper_Res_Comment=By Dateranoth - Feburary 5, 2017
#AutoIt3Wrapper_Res_Description=Utility for Running Conan Server
#AutoIt3Wrapper_Res_Fileversion=2.2.0.1
#AutoIt3Wrapper_Res_LegalCopyright=Dateranoth @ https://gamercide.com
#AutoIt3Wrapper_Res_Language=1033
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
;By Dateranoth - Feburary 4, 2017
;Used by https://gamercide.com on their server
;Feel free to change, adapt, and distribute

#include <Date.au3>
#include <Process.au3>
#include <MsgBoxConstants.au3>
#include <File.au3>
Opt("WinTitleMatchMode", 1) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase

;User Variables
If FileExists("ConanServerUtility.ini") Then
   Local $g_IP = IniRead("ConanServerUtility.ini", "Game Server IP", "ListenIP", "127.0.0.1")
   Local $GamePort = IniRead("ConanServerUtility.ini", "Game Server Port", "GamePort", "27015")
   Local $AdminPass = IniRead("ConanServerUtility.ini", "Admin Password", "AdminPass", "yOuRpaSHeRe")
   Local $MaxPlayers = IniRead("ConanServerUtility.ini", "Max Players", "MaxPlayers", "20")
   Local $serverdir = IniRead("ConanServerUtility.ini", "Server Directory. NO TRAILING SLASH", "serverdir", "C:\Game_Servers\Conan_Exiles_Server")
   Local $UseSteamCMD = IniRead("ConanServerUtility.ini", "Use SteamCMD To Update Server? yes/no", "UseSteamCMD", "yes")
   Local $steamcmddir = IniRead("ConanServerUtility.ini", "SteamCMD Directory. NO TRAILING SLASH", "steamcmddir", "C:\Game_Servers\SteamCMD")
   Local $UseRemoteRestart = IniRead("ConanServerUtility.ini", "Use Remote Restart ?yes/no", "UseRemoteRestart", "no")
   Local $g_Port = IniRead("ConanServerUtility.ini", "Remote Restart Port", "ListenPort", "57520")
   Local $RestartCode = IniRead("ConanServerUtility.ini", "Remote Restart Password", "RestartCode", "FVtb2DXgp8SYwj7J")
   Local $RestartDaily = IniRead("ConanServerUtility.ini", "Restart Server Daily? yes/no", "RestartDaily", "no")
   Local $CheckForUpdate = IniRead("ConanServerUtility.ini", "Check for Update Every Hour? yes/no", "CheckForUpdate", "yes")
   Local $HotHour1 = IniRead("ConanServerUtility.ini", "Daily Restart Hour 1? 00-23", "HotHour1", "00")
   Local $HotHour2 = IniRead("ConanServerUtility.ini", "Daily Restart Hour 2? 00-23", "HotHour2", "00")
   Local $HotHour3 = IniRead("ConanServerUtility.ini", "Daily Restart Hour 3? 00-23", "HotHour3", "00")
   Local $HotHour4 = IniRead("ConanServerUtility.ini", "Daily Restart Hour 4? 00-23", "HotHour4", "00")
   Local $HotMin = IniRead("ConanServerUtility.ini", "Daily Restart Minute? 00-59", "HotMin", "01")
   Local $ExMem = IniRead("ConanServerUtility.ini", "Excessive Memory Amount?", "ExMem", "6000000000")
   Local $ExMemRestart = IniRead("ConanServerUtility.ini", "Restart On Excessive Memory Use? yes/no", "ExMemRestart", "no")
Else
   IniWrite("ConanServerUtility.ini", "Game Server IP", "ListenIP", "127.0.0.1")
   IniWrite("ConanServerUtility.ini", "Game Server Port", "GamePort", "27015")
   IniWrite("ConanServerUtility.ini", "Admin Password", "AdminPass", "yOuRpaSHeRe")
   IniWrite("ConanServerUtility.ini", "Max Players", "MaxPlayers", "20")
   IniWrite("ConanServerUtility.ini", "Server Directory. NO TRAILING SLASH", "serverdir", "C:\Game_Servers\Conan_Exiles_Server")
   IniWrite("ConanServerUtility.ini", "Use SteamCMD To Update Server? yes/no", "UseSteamCMD", "yes")
   IniWrite("ConanServerUtility.ini", "SteamCMD Directory. NO TRAILING SLASH", "steamcmddir", "C:\Game_Servers\SteamCMD")
   IniWrite("ConanServerUtility.ini", "Use Remote Restart ?yes/no", "UseRemoteRestart", "no")
   IniWrite("ConanServerUtility.ini", "Remote Restart Port", "ListenPort", "57520")
   IniWrite("ConanServerUtility.ini", "Remote Restart Password", "RestartCode", "FVtb2DXgp8SYwj7J")
   IniWrite("ConanServerUtility.ini", "Restart Server Daily? yes/no", "RestartDaily", "no")
   IniWrite("ConanServerUtility.ini", "Check for Update Every Hour? yes/no", "CheckForUpdate", "yes")
   IniWrite("ConanServerUtility.ini", "Daily Restart Hour 1? 00-23", "HotHour1", "00")
   IniWrite("ConanServerUtility.ini", "Daily Restart Hour 2? 00-23", "HotHour2", "00")
   IniWrite("ConanServerUtility.ini", "Daily Restart Hour 3? 00-23", "HotHour3", "00")
   IniWrite("ConanServerUtility.ini", "Daily Restart Hour 4? 00-23", "HotHour4", "00")
   IniWrite("ConanServerUtility.ini", "Daily Restart Minute? 00-59", "HotMin", "01")
   IniWrite("ConanServerUtility.ini", "Excessive Memory Amount?", "ExMem", "6000000000")
   IniWrite("ConanServerUtility.ini", "Restart On Excessive Memory Use? yes/no", "ExMemRestart", "no")
   MsgBox(4096, "Default INI File Made", "Please Modify Default Values and Restart Script")
   Exit
EndIf

OnAutoItExitRegister("Gamercide")

Func Gamercide()
	If @exitMethod <> 1 Then
	$Shutdown = MsgBox(4100, "Shut Down?","Do you wish to shutdown the server?",10)
		If $Shutdown = 6 Then
			CloseServer()
		EndIf
		MsgBox(4096, "Thanks for using our Application", "Please visit us at https://gamercide.com",5)
	EndIf
	Exit
EndFunc

Func CloseServer()
	Local $PID = ProcessExists("ConanSandboxServer-Win64-Test.exe")
	ControlSend("Conan Exiles -", "", "", "I" & @CR)
	ControlSend("Conan Exiles -", "", "", "I" & @CR)
	ControlSend("Conan Exiles -", "", "", "^C")
	WinWaitClose("Conan Exiles -", "", 60)
	If $PID Then
		ProcessClose($PID)
    EndIf
EndFunc

Func UpdateCheck()
	Local $oXML = ObjCreate("Microsoft.XMLHTTP")
	$oXML.Open("GET", "http://steamcommunity.com/games/440900/rss/", 0)
	$oXML.Send

	Global $sFile = _TempFile(@ScriptDir, '~', '.xml')
	FileWrite($sFile, $oXML.responseText)

	$sXML = $sFile
	Local $oXML = ObjCreate("Microsoft.XMLDOM")
	$oXML.Load($sXML)
	Local $oNames = $oXML.selectNodes("//rss/channel/item/title")
	Local $aMyDate, $aMyTime
	_DateTimeSplit(_NowCalc(), $aMyDate, $aMyTime)
    Local $cDate = "PATCH "& StringFormat("%02d", $aMyDate[2]) &"."& StringFormat("%02d", $aMyDate[3]) &"."& StringFormat("%04d", $aMyDate[1])
	Local $cFile = @ScriptDir &"/ConanServerUtility_LastUpdate.txt"

	For $oName In $oNames

		If StringRegExp($oName.text,$cDate&"(?i)") Then
				If FileRead(FileOpen($cFile)) = $oName.text Then
					;ConsoleWrite("No New Update" & @CRLF)
					FileClose($cFile)
					ExitLoop
				Else
					FileClose($cFile)
					FileWrite(FileOpen($cFile,2),$oName.text)
					ConsoleWrite($oName.text & @CRLF)
					FileClose($cFile)
					Local $PID = ProcessExists("ConanSandboxServer-Win64-Test.exe")
					If $PID Then
						FileWriteLine(@ScriptDir & "\ConanServerUtility_RestartLog.txt", @MON &"-"& @MDAY &"-"& @YEAR &" "& @HOUR &":"& @MIN &"["& $oName.txt &"] Restart Requested by ConanServerUtility Script")
						CloseServer()
					EndIf
					ExitLoop
				EndIf
		EndIf
	Next
	FileDelete($sFile)
EndFunc

Func _TCP_Server_ClientIP($hSocket)
   Local $pSocketAddress, $aReturn
   $pSocketAddress = DllStructCreate("short;ushort;uint;char[8]")
   $aReturn = DllCall("ws2_32.dll", "int", "getpeername", "int", $hSocket, "ptr", DllStructGetPtr($pSocketAddress), "int*", DllStructGetSize($pSocketAddress))
   If @error Or $aReturn[0] <> 0 Then Return $hSocket
	  $aReturn = DllCall("ws2_32.dll", "str", "inet_ntoa", "int", DllStructGetData($pSocketAddress, 3))
   If @error Then Return $hSocket
	  $pSocketAddress = 0
   Return $aReturn[0]
EndFunc ;==>_TCP_Server_ClientIP

If $UseSteamCMD = "yes" Then
	Local $sFileExists = FileExists($steamcmddir &"\steamcmd.exe")
	If $sFileExists = 0 Then
		MsgBox ( 0x0, "SteamCMD Not Found", "Could not find steamcmd.exe at "& $steamcmddir)
		Exit
	EndIf

Else
	Local $cFileExists = FileExists($serverdir &"\ConanSandboxServer.exe")
	If $cFileExists = 0 Then
		MsgBox ( 0x0, "Conan Server Not Found", "Could not find ConanSandboxServer.exe at "& $serverdir)
		Exit
	EndIf
Endif


If $UseRemoteRestart = "yes" Then
; Start The TCP Services
TCPStartup()
Local $MainSocket = TCPListen($g_IP, $g_Port, 100)
	If $MainSocket = -1 Then
		MsgBox ( 0x0, "TCP Error", "Could not bind to [" &  $g_IP & "] Is this the correct Server IP?")
		Exit
		EndIf
EndIf

While True
If $UseRemoteRestart = "yes" Then
Local $ConnectedSocket = TCPAccept($MainSocket)
If $ConnectedSocket >= 0 Then
$Count = 0
While $Count < 30
$RECV = TCPRecv($ConnectedSocket,512)
   If $RECV = $RestartCode Then
	  Local $PID = ProcessExists("ConanSandboxServer-Win64-Test.exe") ; Will return the PID or 0 if the process isn't found.
	  Local $IP = _TCP_Server_ClientIP($ConnectedSocket)
	  If $PID Then
		 Local $MEM = ProcessGetStats($PID, 0)
		 FileWriteLine(@ScriptDir & "\ConanServerUtility_RestartLog.txt", @MON &"-"& @MDAY &"-"& @YEAR &" "& @HOUR &":"& @MIN &" --Work Memory:"& $MEM[0] & _
		 " --Peak Memory:"& $MEM[1] &" Restart Requested by Remote Host: "& $IP)
		 CloseServer()
		 Sleep (10000)
		 ExitLoop
	  EndIf
	  Else
		FileWriteLine(@ScriptDir & "\ConanServerUtility_RestartLog.txt", @MON &"-"& @MDAY &"-"& @YEAR &" "& @HOUR &":"& @MIN &" Restart ATTEMPT by Remote Host: "& $IP &" WRONG PASSWORD")
		ExitLoop
   EndIf
$Count += 1
Sleep (1000)
WEnd
If $ConnectedSocket <> -1 Then TCPCloseSocket($ConnectedSocket)
EndIf
EndIf


Local $PID = ProcessExists("ConanSandboxServer-Win64-Test.exe")
If $PID = 0 Then
	If $UseSteamCMD = "yes" Then
		RunWait(""& $steamcmddir &"\steamcmd.exe +@ShutdownOnFailedCommand 1 +@NoPromptForPassword 1 +login anonymous +force_install_dir "& $serverdir &" +app_update 443030 validate +quit")
	EndIf
	If $CheckForUpdate = "yes" Then
		UpdateCheck()
	EndIf
	Run(""& $serverdir &"\ConanSandbox\Binaries\Win64\ConanSandboxServer-Win64-Test.exe ConanSandBox?MULTIHOME="& $g_IP &"?QueryPort="& $GamePort &"?MaxPlayers="& $MaxPlayers &"?AdminPassword="& $AdminPass &"?listen -nosteamclient -game -server -log")
	WinWait("Conan Exiles -", "", 70)
Else
   Local $MEM = ProcessGetStats($PID, 0)
   If $MEM[0] > $ExMem And $ExMemRestart = "no" Then
	  FileWriteLine(@ScriptDir & "\ConanServerUtility_ExcessiveMemoryLog.txt", @MON &"-"& @MDAY &"-"& @YEAR &" "& @HOUR &":"& @MIN &" --Work Memory:"& $MEM[0] & _
        " --Peak Memory:"& $MEM[1])
	  Sleep (10000)
   ElseIf $MEM[0] > $ExMem And $ExMemRestart = "yes" Then
	  FileWriteLine(@ScriptDir & "\ConanServerUtility_RestartLog.txt", @MON &"-"& @MDAY &"-"& @YEAR &" "& @HOUR &":"& @MIN &" --Work Memory:"& $MEM[0] & _
	  " --Peak Memory:"& $MEM[1] &" Excessive Memory Use - Restart Requested by ConanServerUtility Script")
	  CloseServer()
	  Sleep (10000)
   EndIf
EndIf

If ((@HOUR = $HotHour1 Or @HOUR = $HotHour2 Or @HOUR = $HotHour3 Or @HOUR = $HotHour4) And @MIN = $HotMin And $RestartDaily = "yes") Then
   Local $PID = ProcessExists("ConanSandboxServer-Win64-Test.exe")
	  If $PID Then
		 Local $MEM = ProcessGetStats($PID, 0)
		 FileWriteLine(@ScriptDir & "\ConanServerUtility_RestartLog.txt", @MON &"-"& @MDAY &"-"& @YEAR &" "& @HOUR &":"& @MIN &" --Work Memory:"& $MEM[0] & _
		 " --Peak Memory:"& $MEM[1] &" Daily Restart Requested by ConanServerUtility Script")
		 CloseServer()
	  EndIf
   Sleep (10000)
EndIf

If @MIN = $HotMin And $CheckForUpdate = "yes" Then
	UpdateCheck()
	Sleep(70000)
EndIf

Sleep (500)
WEnd

 

 

Share this post


Link to post
Share on other sites

V2.2.0.2 Update!

Corrected my request. Needed to have 6 available restarts through the day.

V2.2.0.2 Downloads

Complete Version 2.2.0.2 including Source

Conan Server Utility V2.2.0.2

Conan Server Remote Restart Utility V2.2.0.2

Conan Server Utility V2.2.0.2 Source

Conan Server Remote Restart Utility V2.2.0.2 Source

 

V2.2.0.2 Server Utility Source:

Spoiler

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=favicon.ico
#AutoIt3Wrapper_Res_Comment=By Dateranoth - Feburary 5, 2017
#AutoIt3Wrapper_Res_Description=Utility for Running Conan Server
#AutoIt3Wrapper_Res_Fileversion=2.2.0.2
#AutoIt3Wrapper_Res_LegalCopyright=Dateranoth @ https://gamercide.com
#AutoIt3Wrapper_Res_Language=1033
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
;By Dateranoth - Feburary 4, 2017
;Used by https://gamercide.com on their server
;Feel free to change, adapt, and distribute

#include <Date.au3>
#include <Process.au3>
#include <MsgBoxConstants.au3>
#include <File.au3>
Opt("WinTitleMatchMode", 1) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase

;User Variables
If FileExists("ConanServerUtility.ini") Then
   Local $g_IP = IniRead("ConanServerUtility.ini", "Game Server IP", "ListenIP", "127.0.0.1")
   Local $GamePort = IniRead("ConanServerUtility.ini", "Game Server Port", "GamePort", "27015")
   Local $AdminPass = IniRead("ConanServerUtility.ini", "Admin Password", "AdminPass", "yOuRpaSHeRe")
   Local $MaxPlayers = IniRead("ConanServerUtility.ini", "Max Players", "MaxPlayers", "20")
   Local $serverdir = IniRead("ConanServerUtility.ini", "Server Directory. NO TRAILING SLASH", "serverdir", "C:\Game_Servers\Conan_Exiles_Server")
   Local $UseSteamCMD = IniRead("ConanServerUtility.ini", "Use SteamCMD To Update Server? yes/no", "UseSteamCMD", "yes")
   Local $steamcmddir = IniRead("ConanServerUtility.ini", "SteamCMD Directory. NO TRAILING SLASH", "steamcmddir", "C:\Game_Servers\SteamCMD")
   Local $UseRemoteRestart = IniRead("ConanServerUtility.ini", "Use Remote Restart ?yes/no", "UseRemoteRestart", "no")
   Local $g_Port = IniRead("ConanServerUtility.ini", "Remote Restart Port", "ListenPort", "57520")
   Local $RestartCode = IniRead("ConanServerUtility.ini", "Remote Restart Password", "RestartCode", "FVtb2DXgp8SYwj7J")
   Local $RestartDaily = IniRead("ConanServerUtility.ini", "Restart Server Daily? yes/no", "RestartDaily", "no")
   Local $CheckForUpdate = IniRead("ConanServerUtility.ini", "Check for Update Every Hour? yes/no", "CheckForUpdate", "yes")
   Local $HotHour1 = IniRead("ConanServerUtility.ini", "Daily Restart Hours? 00-23", "HotHour1", "00")
   Local $HotHour2 = IniRead("ConanServerUtility.ini", "Daily Restart Hours? 00-23", "HotHour2", "00")
   Local $HotHour3 = IniRead("ConanServerUtility.ini", "Daily Restart Hours? 00-23", "HotHour3", "00")
   Local $HotHour4 = IniRead("ConanServerUtility.ini", "Daily Restart Hours? 00-23", "HotHour4", "00")
   Local $HotHour5 = IniRead("ConanServerUtility.ini", "Daily Restart Hours? 00-23", "HotHour5", "00")
   Local $HotHour6 = IniRead("ConanServerUtility.ini", "Daily Restart Hours? 00-23", "HotHour6", "00")
   Local $HotMin = IniRead("ConanServerUtility.ini", "Daily Restart Minute? 00-59", "HotMin", "01")
   Local $ExMem = IniRead("ConanServerUtility.ini", "Excessive Memory Amount?", "ExMem", "6000000000")
   Local $ExMemRestart = IniRead("ConanServerUtility.ini", "Restart On Excessive Memory Use? yes/no", "ExMemRestart", "no")
Else
   IniWrite("ConanServerUtility.ini", "Game Server IP", "ListenIP", "127.0.0.1")
   IniWrite("ConanServerUtility.ini", "Game Server Port", "GamePort", "27015")
   IniWrite("ConanServerUtility.ini", "Admin Password", "AdminPass", "yOuRpaSHeRe")
   IniWrite("ConanServerUtility.ini", "Max Players", "MaxPlayers", "20")
   IniWrite("ConanServerUtility.ini", "Server Directory. NO TRAILING SLASH", "serverdir", "C:\Game_Servers\Conan_Exiles_Server")
   IniWrite("ConanServerUtility.ini", "Use SteamCMD To Update Server? yes/no", "UseSteamCMD", "yes")
   IniWrite("ConanServerUtility.ini", "SteamCMD Directory. NO TRAILING SLASH", "steamcmddir", "C:\Game_Servers\SteamCMD")
   IniWrite("ConanServerUtility.ini", "Use Remote Restart ?yes/no", "UseRemoteRestart", "no")
   IniWrite("ConanServerUtility.ini", "Remote Restart Port", "ListenPort", "57520")
   IniWrite("ConanServerUtility.ini", "Remote Restart Password", "RestartCode", "FVtb2DXgp8SYwj7J")
   IniWrite("ConanServerUtility.ini", "Restart Server Daily? yes/no", "RestartDaily", "no")
   IniWrite("ConanServerUtility.ini", "Check for Update Every Hour? yes/no", "CheckForUpdate", "yes")
   IniWrite("ConanServerUtility.ini", "Daily Restart Hours? 00-23", "HotHour1", "00")
   IniWrite("ConanServerUtility.ini", "Daily Restart Hours? 00-23", "HotHour2", "00")
   IniWrite("ConanServerUtility.ini", "Daily Restart Hours? 00-23", "HotHour3", "00")
   IniWrite("ConanServerUtility.ini", "Daily Restart Hours? 00-23", "HotHour4", "00")
   IniWrite("ConanServerUtility.ini", "Daily Restart Hours? 00-23", "HotHour5", "00")
   IniWrite("ConanServerUtility.ini", "Daily Restart Hours? 00-23", "HotHour6", "00")
   IniWrite("ConanServerUtility.ini", "Daily Restart Minute? 00-59", "HotMin", "01")
   IniWrite("ConanServerUtility.ini", "Excessive Memory Amount?", "ExMem", "6000000000")
   IniWrite("ConanServerUtility.ini", "Restart On Excessive Memory Use? yes/no", "ExMemRestart", "no")
   MsgBox(4096, "Default INI File Made", "Please Modify Default Values and Restart Script")
   Exit
EndIf

OnAutoItExitRegister("Gamercide")

Func Gamercide()
	If @exitMethod <> 1 Then
	$Shutdown = MsgBox(4100, "Shut Down?","Do you wish to shutdown the server?",10)
		If $Shutdown = 6 Then
			CloseServer()
		EndIf
		MsgBox(4096, "Thanks for using our Application", "Please visit us at https://gamercide.com",5)
	EndIf
	Exit
EndFunc

Func CloseServer()
	Local $PID = ProcessExists("ConanSandboxServer-Win64-Test.exe")
	ControlSend("Conan Exiles -", "", "", "I" & @CR)
	ControlSend("Conan Exiles -", "", "", "I" & @CR)
	ControlSend("Conan Exiles -", "", "", "^C")
	WinWaitClose("Conan Exiles -", "", 60)
	If $PID Then
		ProcessClose($PID)
    EndIf
EndFunc

Func UpdateCheck()
	Local $oXML = ObjCreate("Microsoft.XMLHTTP")
	$oXML.Open("GET", "http://steamcommunity.com/games/440900/rss/", 0)
	$oXML.Send

	Global $sFile = _TempFile(@ScriptDir, '~', '.xml')
	FileWrite($sFile, $oXML.responseText)

	$sXML = $sFile
	Local $oXML = ObjCreate("Microsoft.XMLDOM")
	$oXML.Load($sXML)
	Local $oNames = $oXML.selectNodes("//rss/channel/item/title")
	Local $aMyDate, $aMyTime
	_DateTimeSplit(_NowCalc(), $aMyDate, $aMyTime)
    Local $cDate = "PATCH "& StringFormat("%02d", $aMyDate[2]) &"."& StringFormat("%02d", $aMyDate[3]) &"."& StringFormat("%04d", $aMyDate[1])
	Local $cFile = @ScriptDir &"/ConanServerUtility_LastUpdate.txt"

	For $oName In $oNames

		If StringRegExp($oName.text,$cDate&"(?i)") Then
				If FileRead(FileOpen($cFile)) = $oName.text Then
					;ConsoleWrite("No New Update" & @CRLF)
					FileClose($cFile)
					ExitLoop
				Else
					FileClose($cFile)
					FileWrite(FileOpen($cFile,2),$oName.text)
					ConsoleWrite($oName.text & @CRLF)
					FileClose($cFile)
					Local $PID = ProcessExists("ConanSandboxServer-Win64-Test.exe")
					If $PID Then
						FileWriteLine(@ScriptDir & "\ConanServerUtility_RestartLog.txt", @MON &"-"& @MDAY &"-"& @YEAR &" "& @HOUR &":"& @MIN &"["& $oName.txt &"] Restart Requested by ConanServerUtility Script")
						CloseServer()
					EndIf
					ExitLoop
				EndIf
		EndIf
	Next
	FileDelete($sFile)
EndFunc

Func _TCP_Server_ClientIP($hSocket)
   Local $pSocketAddress, $aReturn
   $pSocketAddress = DllStructCreate("short;ushort;uint;char[8]")
   $aReturn = DllCall("ws2_32.dll", "int", "getpeername", "int", $hSocket, "ptr", DllStructGetPtr($pSocketAddress), "int*", DllStructGetSize($pSocketAddress))
   If @error Or $aReturn[0] <> 0 Then Return $hSocket
	  $aReturn = DllCall("ws2_32.dll", "str", "inet_ntoa", "int", DllStructGetData($pSocketAddress, 3))
   If @error Then Return $hSocket
	  $pSocketAddress = 0
   Return $aReturn[0]
EndFunc ;==>_TCP_Server_ClientIP

If $UseSteamCMD = "yes" Then
	Local $sFileExists = FileExists($steamcmddir &"\steamcmd.exe")
	If $sFileExists = 0 Then
		MsgBox ( 0x0, "SteamCMD Not Found", "Could not find steamcmd.exe at "& $steamcmddir)
		Exit
	EndIf

Else
	Local $cFileExists = FileExists($serverdir &"\ConanSandboxServer.exe")
	If $cFileExists = 0 Then
		MsgBox ( 0x0, "Conan Server Not Found", "Could not find ConanSandboxServer.exe at "& $serverdir)
		Exit
	EndIf
Endif


If $UseRemoteRestart = "yes" Then
; Start The TCP Services
TCPStartup()
Local $MainSocket = TCPListen($g_IP, $g_Port, 100)
	If $MainSocket = -1 Then
		MsgBox ( 0x0, "TCP Error", "Could not bind to [" &  $g_IP & "] Is this the correct Server IP?")
		Exit
		EndIf
EndIf

While True
If $UseRemoteRestart = "yes" Then
Local $ConnectedSocket = TCPAccept($MainSocket)
If $ConnectedSocket >= 0 Then
$Count = 0
While $Count < 30
$RECV = TCPRecv($ConnectedSocket,512)
   If $RECV = $RestartCode Then
	  Local $PID = ProcessExists("ConanSandboxServer-Win64-Test.exe") ; Will return the PID or 0 if the process isn't found.
	  Local $IP = _TCP_Server_ClientIP($ConnectedSocket)
	  If $PID Then
		 Local $MEM = ProcessGetStats($PID, 0)
		 FileWriteLine(@ScriptDir & "\ConanServerUtility_RestartLog.txt", @MON &"-"& @MDAY &"-"& @YEAR &" "& @HOUR &":"& @MIN &" --Work Memory:"& $MEM[0] & _
		 " --Peak Memory:"& $MEM[1] &" Restart Requested by Remote Host: "& $IP)
		 CloseServer()
		 Sleep (10000)
		 ExitLoop
	  EndIf
	  Else
		FileWriteLine(@ScriptDir & "\ConanServerUtility_RestartLog.txt", @MON &"-"& @MDAY &"-"& @YEAR &" "& @HOUR &":"& @MIN &" Restart ATTEMPT by Remote Host: "& $IP &" WRONG PASSWORD")
		ExitLoop
   EndIf
$Count += 1
Sleep (1000)
WEnd
If $ConnectedSocket <> -1 Then TCPCloseSocket($ConnectedSocket)
EndIf
EndIf


Local $PID = ProcessExists("ConanSandboxServer-Win64-Test.exe")
If $PID = 0 Then
	If $UseSteamCMD = "yes" Then
		RunWait(""& $steamcmddir &"\steamcmd.exe +@ShutdownOnFailedCommand 1 +@NoPromptForPassword 1 +login anonymous +force_install_dir "& $serverdir &" +app_update 443030 validate +quit")
	EndIf
	If $CheckForUpdate = "yes" Then
		UpdateCheck()
	EndIf
	Run(""& $serverdir &"\ConanSandbox\Binaries\Win64\ConanSandboxServer-Win64-Test.exe ConanSandBox?MULTIHOME="& $g_IP &"?QueryPort="& $GamePort &"?MaxPlayers="& $MaxPlayers &"?AdminPassword="& $AdminPass &"?listen -nosteamclient -game -server -log")
	WinWait("Conan Exiles -", "", 70)
Else
   Local $MEM = ProcessGetStats($PID, 0)
   If $MEM[0] > $ExMem And $ExMemRestart = "no" Then
	  FileWriteLine(@ScriptDir & "\ConanServerUtility_ExcessiveMemoryLog.txt", @MON &"-"& @MDAY &"-"& @YEAR &" "& @HOUR &":"& @MIN &" --Work Memory:"& $MEM[0] & _
        " --Peak Memory:"& $MEM[1])
	  Sleep (10000)
   ElseIf $MEM[0] > $ExMem And $ExMemRestart = "yes" Then
	  FileWriteLine(@ScriptDir & "\ConanServerUtility_RestartLog.txt", @MON &"-"& @MDAY &"-"& @YEAR &" "& @HOUR &":"& @MIN &" --Work Memory:"& $MEM[0] & _
	  " --Peak Memory:"& $MEM[1] &" Excessive Memory Use - Restart Requested by ConanServerUtility Script")
	  CloseServer()
	  Sleep (10000)
   EndIf
EndIf

If ((@HOUR = $HotHour1 Or @HOUR = $HotHour2 Or @HOUR = $HotHour3 Or @HOUR = $HotHour4 Or @HOUR = $HotHour5 Or @HOUR = $HotHour6) And @MIN = $HotMin And $RestartDaily = "yes") Then
   Local $PID = ProcessExists("ConanSandboxServer-Win64-Test.exe")
	  If $PID Then
		 Local $MEM = ProcessGetStats($PID, 0)
		 FileWriteLine(@ScriptDir & "\ConanServerUtility_RestartLog.txt", @MON &"-"& @MDAY &"-"& @YEAR &" "& @HOUR &":"& @MIN &" --Work Memory:"& $MEM[0] & _
		 " --Peak Memory:"& $MEM[1] &" Daily Restart Requested by ConanServerUtility Script")
		 CloseServer()
	  EndIf
   Sleep (10000)
EndIf

If @MIN = $HotMin And $CheckForUpdate = "yes" Then
	UpdateCheck()
	Sleep(70000)
EndIf

Sleep (500)
WEnd

 

 

Share this post


Link to post
Share on other sites

Hi, Im having a problem with my server and would like your help. 

 

when i use your script i get some errors and server wont show/startup fully.

 

Server is not showing online. ive ran the server before, day of launch till now. because i want an auto update. 

 

when i use the start.bat that the server gives me when u create it it works fine. not sure whats wrong. would u want me to send u my log?

 

 

this spams my whole server log. probably 1000 times. 

Quote

 

[2017.02.05-20.17.58:530][451]LogScript:Warning: Script call stack:
        Function /Game/BP_TimeOfDayManager.BP_TimeOfDayManager_C:NotifyNewHour
        Function /Game/BP_TimeOfDayManager.BP_TimeOfDayManager_C:ExecuteUbergraph_BP_TimeOfDayManager

[2017.02.05-20.17.58:530][451]LogScript:Warning: Script call stack:
        Function /Game/BP_TimeOfDayManager.BP_TimeOfDayManager_C:NotifyNewHour
        Function /Game/BP_TimeOfDayManager.BP_TimeOfDayManager_C:ExecuteUbergraph_BP_TimeOfDayManager

 

 

 

 

Share this post


Link to post
Share on other sites

V2.2.0.3 Update!

BUG FIX RELEASE!!! Download this release immediately and delete your current INI file. This fixes a major bug that crashes the script when attempting to update the server.

 

V2.2.0.3 Downloads

Complete Version 2.2.0.3 including Source

Conan Server Utility V2.2.0.3

Conan Server Remote Restart Utility V2.2.0.3

Conan Server Utility V2.2.0.3 Source

Conan Server Remote Restart Utility V2.2.0.3 Source

 

V2.2.0.3 Server Utility Source:

Spoiler

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=favicon.ico
#AutoIt3Wrapper_Res_Comment=By Dateranoth - Feburary 5, 2017
#AutoIt3Wrapper_Res_Description=Utility for Running Conan Server
#AutoIt3Wrapper_Res_Fileversion=2.2.0.3
#AutoIt3Wrapper_Res_LegalCopyright=Dateranoth @ https://gamercide.com
#AutoIt3Wrapper_Res_Language=1033
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
;By Dateranoth - Feburary 5, 2017
;Used by https://gamercide.com on their server
;Feel free to change, adapt, and distribute

#include <Date.au3>
#include <Process.au3>
#include <MsgBoxConstants.au3>
#include <File.au3>
Opt("WinTitleMatchMode", 1) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase

;User Variables
If FileExists("ConanServerUtility.ini") Then
   Local $g_IP = IniRead("ConanServerUtility.ini", "Game Server IP", "ListenIP", "127.0.0.1")
   Local $GamePort = IniRead("ConanServerUtility.ini", "Game Server Port", "GamePort", "27015")
   Local $AdminPass = IniRead("ConanServerUtility.ini", "Admin Password", "AdminPass", "yOuRpaSHeRe")
   Local $MaxPlayers = IniRead("ConanServerUtility.ini", "Max Players", "MaxPlayers", "20")
   Local $serverdir = IniRead("ConanServerUtility.ini", "Server Directory. NO TRAILING SLASH", "serverdir", "C:\Game_Servers\Conan_Exiles_Server")
   Local $UseSteamCMD = IniRead("ConanServerUtility.ini", "Use SteamCMD To Update Server? yes/no", "UseSteamCMD", "yes")
   Local $steamcmddir = IniRead("ConanServerUtility.ini", "SteamCMD Directory. NO TRAILING SLASH", "steamcmddir", "C:\Game_Servers\SteamCMD")
   Local $UseRemoteRestart = IniRead("ConanServerUtility.ini", "Use Remote Restart ?yes/no", "UseRemoteRestart", "no")
   Local $g_Port = IniRead("ConanServerUtility.ini", "Remote Restart Port", "ListenPort", "57520")
   Local $RestartCode = IniRead("ConanServerUtility.ini", "Remote Restart Password", "RestartCode", "FVtb2DXgp8SYwj7J")
   Local $RestartDaily = IniRead("ConanServerUtility.ini", "Restart Server Daily? yes/no", "RestartDaily", "no")
   Local $CheckForUpdate = IniRead("ConanServerUtility.ini", "Check for Update Every Hour? yes/no", "CheckForUpdate", "yes")
   Local $HotHour1 = IniRead("ConanServerUtility.ini", "Daily Restart Hours? 00-23", "HotHour1", "00")
   Local $HotHour2 = IniRead("ConanServerUtility.ini", "Daily Restart Hours? 00-23", "HotHour2", "00")
   Local $HotHour3 = IniRead("ConanServerUtility.ini", "Daily Restart Hours? 00-23", "HotHour3", "00")
   Local $HotHour4 = IniRead("ConanServerUtility.ini", "Daily Restart Hours? 00-23", "HotHour4", "00")
   Local $HotHour5 = IniRead("ConanServerUtility.ini", "Daily Restart Hours? 00-23", "HotHour5", "00")
   Local $HotHour6 = IniRead("ConanServerUtility.ini", "Daily Restart Hours? 00-23", "HotHour6", "00")
   Local $HotMin = IniRead("ConanServerUtility.ini", "Daily Restart Minute? 00-59", "HotMin", "01")
   Local $ExMem = IniRead("ConanServerUtility.ini", "Excessive Memory Amount?", "ExMem", "6000000000")
   Local $ExMemRestart = IniRead("ConanServerUtility.ini", "Restart On Excessive Memory Use? yes/no", "ExMemRestart", "no")
Else
   IniWrite("ConanServerUtility.ini", "Game Server IP", "ListenIP", "127.0.0.1")
   IniWrite("ConanServerUtility.ini", "Game Server Port", "GamePort", "27015")
   IniWrite("ConanServerUtility.ini", "Admin Password", "AdminPass", "yOuRpaSHeRe")
   IniWrite("ConanServerUtility.ini", "Max Players", "MaxPlayers", "20")
   IniWrite("ConanServerUtility.ini", "Server Directory. NO TRAILING SLASH", "serverdir", "C:\Game_Servers\Conan_Exiles_Server")
   IniWrite("ConanServerUtility.ini", "Use SteamCMD To Update Server? yes/no", "UseSteamCMD", "yes")
   IniWrite("ConanServerUtility.ini", "SteamCMD Directory. NO TRAILING SLASH", "steamcmddir", "C:\Game_Servers\SteamCMD")
   IniWrite("ConanServerUtility.ini", "Use Remote Restart ?yes/no", "UseRemoteRestart", "no")
   IniWrite("ConanServerUtility.ini", "Remote Restart Port", "ListenPort", "57520")
   IniWrite("ConanServerUtility.ini", "Remote Restart Password", "RestartCode", "FVtb2DXgp8SYwj7J")
   IniWrite("ConanServerUtility.ini", "Restart Server Daily? yes/no", "RestartDaily", "no")
   IniWrite("ConanServerUtility.ini", "Check for Update Every Hour? yes/no", "CheckForUpdate", "yes")
   IniWrite("ConanServerUtility.ini", "Daily Restart Hours? 00-23", "HotHour1", "00")
   IniWrite("ConanServerUtility.ini", "Daily Restart Hours? 00-23", "HotHour2", "00")
   IniWrite("ConanServerUtility.ini", "Daily Restart Hours? 00-23", "HotHour3", "00")
   IniWrite("ConanServerUtility.ini", "Daily Restart Hours? 00-23", "HotHour4", "00")
   IniWrite("ConanServerUtility.ini", "Daily Restart Hours? 00-23", "HotHour5", "00")
   IniWrite("ConanServerUtility.ini", "Daily Restart Hours? 00-23", "HotHour6", "00")
   IniWrite("ConanServerUtility.ini", "Daily Restart Minute? 00-59", "HotMin", "01")
   IniWrite("ConanServerUtility.ini", "Excessive Memory Amount?", "ExMem", "6000000000")
   IniWrite("ConanServerUtility.ini", "Restart On Excessive Memory Use? yes/no", "ExMemRestart", "no")
   MsgBox(4096, "Default INI File Made", "Please Modify Default Values and Restart Script")
   Exit
EndIf

OnAutoItExitRegister("Gamercide")

Global $sFile = ""

Func Gamercide()
	If @exitMethod <> 1 Then
	$Shutdown = MsgBox(4100, "Shut Down?","Do you wish to shutdown the server?",10)
		If $Shutdown = 6 Then
			CloseServer()
		EndIf
		MsgBox(4096, "Thanks for using our Application", "Please visit us at https://gamercide.com",5)
	EndIf
	Exit
EndFunc

Func CloseServer()
	Local $PID = ProcessExists("ConanSandboxServer-Win64-Test.exe")
	ControlSend("Conan Exiles -", "", "", "I" & @CR)
	ControlSend("Conan Exiles -", "", "", "I" & @CR)
	ControlSend("Conan Exiles -", "", "", "^C")
	WinWaitClose("Conan Exiles -", "", 60)
	If $PID Then
		ProcessClose($PID)
    EndIf
EndFunc

Func GetRSS()
	Local $oXML = ObjCreate("Microsoft.XMLHTTP")
	$oXML.Open("GET", "http://steamcommunity.com/games/440900/rss/", 0)
	$oXML.Send

	$sFile = _TempFile(@ScriptDir, '~', '.xml')
	FileWrite($sFile, $oXML.responseText)
EndFunc

Func ParseRSS()
	$sXML = $sFile
	Local $oXML = ObjCreate("Microsoft.XMLDOM")
	$oXML.Load($sXML)
	Local $oNames = $oXML.selectNodes("//rss/channel/item/title")
	Local $aMyDate, $aMyTime
	_DateTimeSplit(_NowCalc(), $aMyDate, $aMyTime)
    Local $cDate = "PATCH "& StringFormat("%02d", $aMyDate[3]) &"."& StringFormat("%02d", $aMyDate[2]) &"."& StringFormat("%04d", $aMyDate[1])
	Local $cFile = @ScriptDir &"\ConanServerUtility_LastUpdate.txt"
	For $oName In $oNames

		If StringRegExp($oName.text,$cDate&"(?i)") Then
				If FileRead($cFile) = $oName.text Then
					;ConsoleWrite("No New Update" & @CRLF)
					ExitLoop
				Else
					FileDelete($cFile)
					FileWrite($cFile,$oName.text)
					Local $PID = ProcessExists("ConanSandboxServer-Win64-Test.exe")
					If $PID Then
						FileWriteLine(@ScriptDir & "\ConanServerUtility_RestartLog.txt", @MON &"-"& @MDAY &"-"& @YEAR &" "& @HOUR &":"& @MIN &" ["& $oName.text &"] Daily Restart Requested by ConanServerUtility Script")
						CloseServer()
					EndIf
					ExitLoop
				EndIf
		EndIf
	Next
EndFunc

Func UpdateCheck()
	GetRSS()
	ParseRSS()
	FileDelete($sFile)
EndFunc

Func _TCP_Server_ClientIP($hSocket)
   Local $pSocketAddress, $aReturn
   $pSocketAddress = DllStructCreate("short;ushort;uint;char[8]")
   $aReturn = DllCall("ws2_32.dll", "int", "getpeername", "int", $hSocket, "ptr", DllStructGetPtr($pSocketAddress), "int*", DllStructGetSize($pSocketAddress))
   If @error Or $aReturn[0] <> 0 Then Return $hSocket
	  $aReturn = DllCall("ws2_32.dll", "str", "inet_ntoa", "int", DllStructGetData($pSocketAddress, 3))
   If @error Then Return $hSocket
	  $pSocketAddress = 0
   Return $aReturn[0]
EndFunc ;==>_TCP_Server_ClientIP

If $UseSteamCMD = "yes" Then
	Local $sFileExists = FileExists($steamcmddir &"\steamcmd.exe")
	If $sFileExists = 0 Then
		MsgBox ( 0x0, "SteamCMD Not Found", "Could not find steamcmd.exe at "& $steamcmddir)
		Exit
	EndIf

Else
	Local $cFileExists = FileExists($serverdir &"\ConanSandboxServer.exe")
	If $cFileExists = 0 Then
		MsgBox ( 0x0, "Conan Server Not Found", "Could not find ConanSandboxServer.exe at "& $serverdir)
		Exit
	EndIf
Endif


If $UseRemoteRestart = "yes" Then
; Start The TCP Services
TCPStartup()
Local $MainSocket = TCPListen($g_IP, $g_Port, 100)
	If $MainSocket = -1 Then
		MsgBox ( 0x0, "TCP Error", "Could not bind to [" &  $g_IP & "] Is this the correct Server IP?")
		Exit
		EndIf
EndIf

While True
If $UseRemoteRestart = "yes" Then
Local $ConnectedSocket = TCPAccept($MainSocket)
If $ConnectedSocket >= 0 Then
$Count = 0
While $Count < 30
$RECV = TCPRecv($ConnectedSocket,512)
   If $RECV = $RestartCode Then
	  Local $PID = ProcessExists("ConanSandboxServer-Win64-Test.exe") ; Will return the PID or 0 if the process isn't found.
	  If $PID Then
		 Local $IP = _TCP_Server_ClientIP($ConnectedSocket)
		 Local $MEM = ProcessGetStats($PID, 0)
		 FileWriteLine(@ScriptDir & "\ConanServerUtility_RestartLog.txt", @MON &"-"& @MDAY &"-"& @YEAR &" "& @HOUR &":"& @MIN &" --Work Memory:"& $MEM[0] & _
		 " --Peak Memory:"& $MEM[1] &" Restart Requested by Remote Host: "& $IP)
		 CloseServer()
		 Sleep (10000)
		 ExitLoop
	  EndIf
	  Else
	    Local $IP = _TCP_Server_ClientIP($ConnectedSocket)
		FileWriteLine(@ScriptDir & "\ConanServerUtility_RestartLog.txt", @MON &"-"& @MDAY &"-"& @YEAR &" "& @HOUR &":"& @MIN &" Restart ATTEMPT by Remote Host: "& $IP &" WRONG PASSWORD")
		ExitLoop
   EndIf
$Count += 1
Sleep (1000)
WEnd
If $ConnectedSocket <> -1 Then TCPCloseSocket($ConnectedSocket)
EndIf
EndIf


Local $PID = ProcessExists("ConanSandboxServer-Win64-Test.exe")
If $PID = 0 Then
	If $UseSteamCMD = "yes" Then
		RunWait(""& $steamcmddir &"\steamcmd.exe +@ShutdownOnFailedCommand 1 +@NoPromptForPassword 1 +login anonymous +force_install_dir "& $serverdir &" +app_update 443030 validate +quit")
	EndIf
	If $CheckForUpdate = "yes" Then
		UpdateCheck()
	EndIf
	Run(""& $serverdir &"\ConanSandbox\Binaries\Win64\ConanSandboxServer-Win64-Test.exe ConanSandBox?MULTIHOME="& $g_IP &"?QueryPort="& $GamePort &"?MaxPlayers="& $MaxPlayers &"?AdminPassword="& $AdminPass &"?listen -nosteamclient -game -server -log")
	WinWait("Conan Exiles -", "", 70)
Else
   Local $MEM = ProcessGetStats($PID, 0)
   If $MEM[0] > $ExMem And $ExMemRestart = "no" Then
	  FileWriteLine(@ScriptDir & "\ConanServerUtility_ExcessiveMemoryLog.txt", @MON &"-"& @MDAY &"-"& @YEAR &" "& @HOUR &":"& @MIN &" --Work Memory:"& $MEM[0] & _
        " --Peak Memory:"& $MEM[1])
	  Sleep (10000)
   ElseIf $MEM[0] > $ExMem And $ExMemRestart = "yes" Then
	  FileWriteLine(@ScriptDir & "\ConanServerUtility_RestartLog.txt", @MON &"-"& @MDAY &"-"& @YEAR &" "& @HOUR &":"& @MIN &" --Work Memory:"& $MEM[0] & _
	  " --Peak Memory:"& $MEM[1] &" Excessive Memory Use - Restart Requested by ConanServerUtility Script")
	  CloseServer()
	  Sleep (10000)
   EndIf
EndIf

If ((@HOUR = $HotHour1 Or @HOUR = $HotHour2 Or @HOUR = $HotHour3 Or @HOUR = $HotHour4 Or @HOUR = $HotHour5 Or @HOUR = $HotHour6) And @MIN = $HotMin And $RestartDaily = "yes") Then
   Local $PID = ProcessExists("ConanSandboxServer-Win64-Test.exe")
	  If $PID Then
		 Local $MEM = ProcessGetStats($PID, 0)
		 FileWriteLine(@ScriptDir & "\ConanServerUtility_RestartLog.txt", @MON &"-"& @MDAY &"-"& @YEAR &" "& @HOUR &":"& @MIN &" --Work Memory:"& $MEM[0] & _
		 " --Peak Memory:"& $MEM[1] &" Daily Restart Requested by ConanServerUtility Script")
		 CloseServer()
	  EndIf
   Sleep (10000)
EndIf

If @MIN = $HotMin And $CheckForUpdate = "yes" Then
	UpdateCheck()
	Sleep(70000)
EndIf

Sleep (500)
WEnd

 

 

Share this post


Link to post
Share on other sites
2 hours ago, fallen said:

Hi, Im having a problem with my server and would like your help. 

 

when i use your script i get some errors and server wont show/startup fully.

 

Server is not showing online. ive ran the server before, day of launch till now. because i want an auto update. 

 

when i use the start.bat that the server gives me when u create it it works fine. not sure whats wrong. would u want me to send u my log?

 

 

this spams my whole server log. probably 1000 times. 

 

 

 

 

Could you download the latest version of the utility and try to run it again? [MASTER DOWNLOAD]

 

If it still doesn't work, send me a log file and your INI settings (remove any passwords)

Share this post


Link to post
Share on other sites

Hi :)

Thanks for the hard work, @Dateranoth, The script has been really helpful with a server im helping.

Ive been having an error when trying to use the remote updater (2.2.0.2, will try with the newest update when the server admin wakes up). It is listed as Error Code 10038.

Any idea of what is causing this? 

 

Thanks a bunch again!

Share this post


Link to post
Share on other sites

@Xaring

That error likely means you are not able to connect to the server. Either the port is not open through the firewall or you have entered the wrong IP/Port in the INI file. It will only accept IPs. No names.  Also, if he's still running v2.2.0.2 it might have crashed on the server side. He needs to update as soon as possible.

Share this post


Link to post
Share on other sites

V2.2.1.0 Update!

This is a feature release. It adds two options to the INI file. One is to disable using MULTIHOME to set the IP. Set BindIP=no if you are having connection issues.  Also, adds an option to close the windows that come up when running the server with steam open. This will automatically close them and continue to start the server. Set SteamFix=yes

 

V2.2.1.0 Downloads

Complete Version 2.2.1.0 including Source

Conan Server Utility V2.2.1.0

Conan Server Remote Restart Utility V2.2.1.0

Conan Server Utility V2.2.1.0 Source

Conan Server Remote Restart Utility V2.2.1.0 Source

 

V2.2.1.0 Server Utility Source:

Spoiler

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=favicon.ico
#AutoIt3Wrapper_Res_Comment=By Dateranoth - Feburary 5, 2017
#AutoIt3Wrapper_Res_Description=Utility for Running Conan Server
#AutoIt3Wrapper_Res_Fileversion=2.2.1.0
#AutoIt3Wrapper_Res_LegalCopyright=Dateranoth @ https://gamercide.com
#AutoIt3Wrapper_Res_Language=1033
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
;By Dateranoth - Feburary 5, 2017
;Used by https://gamercide.com on their server
;Feel free to change, adapt, and distribute

#include <Date.au3>
#include <Process.au3>
#include <MsgBoxConstants.au3>
#include <File.au3>
Opt("WinTitleMatchMode", 1) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase

;User Variables
If FileExists("ConanServerUtility.ini") Then
   Local $BindIP = IniRead("ConanServerUtility.ini", "Use MULTIHOME to Bind IP? Disable if having connection issues (yes/no)", "BindIP", "yes")
   Local $g_IP = IniRead("ConanServerUtility.ini", "Game Server IP", "ListenIP", "127.0.0.1")
   Local $GamePort = IniRead("ConanServerUtility.ini", "Game Server Port", "GamePort", "27015")
   Local $AdminPass = IniRead("ConanServerUtility.ini", "Admin Password", "AdminPass", "yOuRpaSHeRe")
   Local $MaxPlayers = IniRead("ConanServerUtility.ini", "Max Players", "MaxPlayers", "20")
   Local $serverdir = IniRead("ConanServerUtility.ini", "Server Directory. NO TRAILING SLASH", "serverdir", "C:\Game_Servers\Conan_Exiles_Server")
   Local $UseSteamCMD = IniRead("ConanServerUtility.ini", "Use SteamCMD To Update Server? yes/no", "UseSteamCMD", "yes")
   Local $steamcmddir = IniRead("ConanServerUtility.ini", "SteamCMD Directory. NO TRAILING SLASH", "steamcmddir", "C:\Game_Servers\SteamCMD")
   Local $UseRemoteRestart = IniRead("ConanServerUtility.ini", "Use Remote Restart ?yes/no", "UseRemoteRestart", "no")
   Local $g_Port = IniRead("ConanServerUtility.ini", "Remote Restart Port", "ListenPort", "57520")
   Local $RestartCode = IniRead("ConanServerUtility.ini", "Remote Restart Password", "RestartCode", "FVtb2DXgp8SYwj7J")
   Local $RestartDaily = IniRead("ConanServerUtility.ini", "Restart Server Daily? yes/no", "RestartDaily", "no")
   Local $CheckForUpdate = IniRead("ConanServerUtility.ini", "Check for Update Every Hour? yes/no", "CheckForUpdate", "yes")
   Local $HotHour1 = IniRead("ConanServerUtility.ini", "Daily Restart Hours? 00-23", "HotHour1", "00")
   Local $HotHour2 = IniRead("ConanServerUtility.ini", "Daily Restart Hours? 00-23", "HotHour2", "00")
   Local $HotHour3 = IniRead("ConanServerUtility.ini", "Daily Restart Hours? 00-23", "HotHour3", "00")
   Local $HotHour4 = IniRead("ConanServerUtility.ini", "Daily Restart Hours? 00-23", "HotHour4", "00")
   Local $HotHour5 = IniRead("ConanServerUtility.ini", "Daily Restart Hours? 00-23", "HotHour5", "00")
   Local $HotHour6 = IniRead("ConanServerUtility.ini", "Daily Restart Hours? 00-23", "HotHour6", "00")
   Local $HotMin = IniRead("ConanServerUtility.ini", "Daily Restart Minute? 00-59", "HotMin", "01")
   Local $ExMem = IniRead("ConanServerUtility.ini", "Excessive Memory Amount?", "ExMem", "6000000000")
   Local $ExMemRestart = IniRead("ConanServerUtility.ini", "Restart On Excessive Memory Use? yes/no", "ExMemRestart", "no")
   Local $SteamFix = IniRead("ConanServerUtility.ini", "Running Server with Steam Open? (yes/no)", "SteamFix", "no")
Else
   IniWrite("ConanServerUtility.ini", "Use MULTIHOME to Bind IP? Disable if having connection issues (yes/no)", "BindIP", "yes")
   IniWrite("ConanServerUtility.ini", "Game Server IP", "ListenIP", "127.0.0.1")
   IniWrite("ConanServerUtility.ini", "Game Server Port", "GamePort", "27015")
   IniWrite("ConanServerUtility.ini", "Admin Password", "AdminPass", "yOuRpaSHeRe")
   IniWrite("ConanServerUtility.ini", "Max Players", "MaxPlayers", "20")
   IniWrite("ConanServerUtility.ini", "Server Directory. NO TRAILING SLASH", "serverdir", "C:\Game_Servers\Conan_Exiles_Server")
   IniWrite("ConanServerUtility.ini", "Use SteamCMD To Update Server? yes/no", "UseSteamCMD", "yes")
   IniWrite("ConanServerUtility.ini", "SteamCMD Directory. NO TRAILING SLASH", "steamcmddir", "C:\Game_Servers\SteamCMD")
   IniWrite("ConanServerUtility.ini", "Use Remote Restart ?yes/no", "UseRemoteRestart", "no")
   IniWrite("ConanServerUtility.ini", "Remote Restart Port", "ListenPort", "57520")
   IniWrite("ConanServerUtility.ini", "Remote Restart Password", "RestartCode", "FVtb2DXgp8SYwj7J")
   IniWrite("ConanServerUtility.ini", "Restart Server Daily? yes/no", "RestartDaily", "no")
   IniWrite("ConanServerUtility.ini", "Check for Update Every Hour? yes/no", "CheckForUpdate", "yes")
   IniWrite("ConanServerUtility.ini", "Daily Restart Hours? 00-23", "HotHour1", "00")
   IniWrite("ConanServerUtility.ini", "Daily Restart Hours? 00-23", "HotHour2", "00")
   IniWrite("ConanServerUtility.ini", "Daily Restart Hours? 00-23", "HotHour3", "00")
   IniWrite("ConanServerUtility.ini", "Daily Restart Hours? 00-23", "HotHour4", "00")
   IniWrite("ConanServerUtility.ini", "Daily Restart Hours? 00-23", "HotHour5", "00")
   IniWrite("ConanServerUtility.ini", "Daily Restart Hours? 00-23", "HotHour6", "00")
   IniWrite("ConanServerUtility.ini", "Daily Restart Minute? 00-59", "HotMin", "01")
   IniWrite("ConanServerUtility.ini", "Excessive Memory Amount?", "ExMem", "6000000000")
   IniWrite("ConanServerUtility.ini", "Restart On Excessive Memory Use? yes/no", "ExMemRestart", "no")
   IniWrite("ConanServerUtility.ini", "Running Server with Steam Open? (yes/no)", "SteamFix", "no")
   MsgBox(4096, "Default INI File Made", "Please Modify Default Values and Restart Script")
   Exit
EndIf

OnAutoItExitRegister("Gamercide")

Global $sFile = ""
Global $Server_EXE = "ConanSandboxServer-Win64-Test.exe"
Func Gamercide()
	If @exitMethod <> 1 Then
	$Shutdown = MsgBox(4100, "Shut Down?","Do you wish to shutdown the server?",10)
		If $Shutdown = 6 Then
			CloseServer()
		EndIf
		MsgBox(4096, "Thanks for using our Application", "Please visit us at https://gamercide.com",5)
	EndIf
	Exit
EndFunc

Func CloseServer()
	Local $PID = ProcessExists(""& $Server_EXE &"")
	ControlSend("Conan Exiles -", "", "", "I" & @CR)
	ControlSend("Conan Exiles -", "", "", "I" & @CR)
	ControlSend("Conan Exiles -", "", "", "^C")
	WinWaitClose("Conan Exiles -", "", 60)
	If $PID Then
		ProcessClose($PID)
    EndIf
EndFunc

Func GetRSS()
	Local $oXML = ObjCreate("Microsoft.XMLHTTP")
	$oXML.Open("GET", "http://steamcommunity.com/games/440900/rss/", 0)
	$oXML.Send

	$sFile = _TempFile(@ScriptDir, '~', '.xml')
	FileWrite($sFile, $oXML.responseText)
EndFunc

Func ParseRSS()
	$sXML = $sFile
	Local $oXML = ObjCreate("Microsoft.XMLDOM")
	$oXML.Load($sXML)
	Local $oNames = $oXML.selectNodes("//rss/channel/item/title")
	Local $aMyDate, $aMyTime
	_DateTimeSplit(_NowCalc(), $aMyDate, $aMyTime)
    Local $cDate = "PATCH "& StringFormat("%02d", $aMyDate[3]) &"."& StringFormat("%02d", $aMyDate[2]) &"."& StringFormat("%04d", $aMyDate[1])
	Local $cFile = @ScriptDir &"\ConanServerUtility_LastUpdate.txt"
	For $oName In $oNames

		If StringRegExp($oName.text,$cDate&"(?i)") Then
				If FileRead($cFile) = $oName.text Then
					;ConsoleWrite("No New Update" & @CRLF)
					ExitLoop
				Else
					FileDelete($cFile)
					FileWrite($cFile,$oName.text)
					Local $PID = ProcessExists(""& $Server_EXE &"")
					If $PID Then
						FileWriteLine(@ScriptDir & "\ConanServerUtility_RestartLog.txt", @MON &"-"& @MDAY &"-"& @YEAR &" "& @HOUR &":"& @MIN &" ["& $oName.text &"] Daily Restart Requested by ConanServerUtility Script")
						CloseServer()
					EndIf
					ExitLoop
				EndIf
		EndIf
	Next
EndFunc

Func UpdateCheck()
	GetRSS()
	ParseRSS()
	FileDelete($sFile)
EndFunc

Func _TCP_Server_ClientIP($hSocket)
   Local $pSocketAddress, $aReturn
   $pSocketAddress = DllStructCreate("short;ushort;uint;char[8]")
   $aReturn = DllCall("ws2_32.dll", "int", "getpeername", "int", $hSocket, "ptr", DllStructGetPtr($pSocketAddress), "int*", DllStructGetSize($pSocketAddress))
   If @error Or $aReturn[0] <> 0 Then Return $hSocket
	  $aReturn = DllCall("ws2_32.dll", "str", "inet_ntoa", "int", DllStructGetData($pSocketAddress, 3))
   If @error Then Return $hSocket
	  $pSocketAddress = 0
   Return $aReturn[0]
EndFunc ;==>_TCP_Server_ClientIP

If $UseSteamCMD = "yes" Then
	Local $sFileExists = FileExists($steamcmddir &"\steamcmd.exe")
	If $sFileExists = 0 Then
		MsgBox ( 0x0, "SteamCMD Not Found", "Could not find steamcmd.exe at "& $steamcmddir)
		Exit
	EndIf

Else
	Local $cFileExists = FileExists($serverdir &"\ConanSandboxServer.exe")
	If $cFileExists = 0 Then
		MsgBox ( 0x0, "Conan Server Not Found", "Could not find ConanSandboxServer.exe at "& $serverdir)
		Exit
	EndIf
Endif


If $UseRemoteRestart = "yes" Then
; Start The TCP Services
TCPStartup()
Local $MainSocket = TCPListen($g_IP, $g_Port, 100)
	If $MainSocket = -1 Then
		MsgBox ( 0x0, "TCP Error", "Could not bind to [" &  $g_IP & "] Is this the correct Server IP?")
		Exit
		EndIf
EndIf

While True
If $UseRemoteRestart = "yes" Then
Local $ConnectedSocket = TCPAccept($MainSocket)
If $ConnectedSocket >= 0 Then
$Count = 0
While $Count < 30
$RECV = TCPRecv($ConnectedSocket,512)
   If $RECV = $RestartCode Then
	  Local $PID = ProcessExists(""& $Server_EXE &"") ; Will return the PID or 0 if the process isn't found.
	  If $PID Then
		 Local $IP = _TCP_Server_ClientIP($ConnectedSocket)
		 Local $MEM = ProcessGetStats($PID, 0)
		 FileWriteLine(@ScriptDir & "\ConanServerUtility_RestartLog.txt", @MON &"-"& @MDAY &"-"& @YEAR &" "& @HOUR &":"& @MIN &" --Work Memory:"& $MEM[0] & _
		 " --Peak Memory:"& $MEM[1] &" Restart Requested by Remote Host: "& $IP)
		 CloseServer()
		 Sleep (10000)
		 ExitLoop
	  EndIf
	  Else
	    Local $IP = _TCP_Server_ClientIP($ConnectedSocket)
		FileWriteLine(@ScriptDir & "\ConanServerUtility_RestartLog.txt", @MON &"-"& @MDAY &"-"& @YEAR &" "& @HOUR &":"& @MIN &" Restart ATTEMPT by Remote Host: "& $IP &" WRONG PASSWORD")
		ExitLoop
   EndIf
$Count += 1
Sleep (1000)
WEnd
If $ConnectedSocket <> -1 Then TCPCloseSocket($ConnectedSocket)
EndIf
EndIf


Local $PID = ProcessExists(""& $Server_EXE &"")
If $PID = 0 Then
	If $UseSteamCMD = "yes" Then
		RunWait(""& $steamcmddir &"\steamcmd.exe +@ShutdownOnFailedCommand 1 +@NoPromptForPassword 1 +login anonymous +force_install_dir "& $serverdir &" +app_update 443030 validate +quit")
	EndIf
	If $CheckForUpdate = "yes" Then
		UpdateCheck()
	EndIf
	If $BindIP = "no" Then
		Run(""& $serverdir &"\ConanSandbox\Binaries\Win64\"& $Server_EXE &" ConanSandBox?QueryPort="& $GamePort &"?MaxPlayers="& $MaxPlayers &"?AdminPassword="& $AdminPass &"?listen -nosteamclient -game -server -log")
	Else
		Run(""& $serverdir &"\ConanSandbox\Binaries\Win64\ConanSandboxServer-Win64-Test.exe ConanSandBox?MULTIHOME="& $g_IP &"?QueryPort="& $GamePort &"?MaxPlayers="& $MaxPlayers &"?AdminPassword="& $AdminPass &"?listen -nosteamclient -game -server -log")
	EndIf
	If $SteamFix = "yes" Then
		WinWait(""& $Server_EXE &" - Entry Point Not Found","",5)
		If WinExists(""& $Server_EXE &" - Entry Point Not Found") Then
			ControlSend(""& $Server_EXE &" - Entry Point Not Found", "", "", "{enter}")
		EndIf
		WinWait(""& $Server_EXE &" - Entry Point Not Found","",5)
		If WinExists(""& $Server_EXE &" - Entry Point Not Found") Then
			ControlSend(""& $Server_EXE &" - Entry Point Not Found", "", "", "{enter}")
		EndIf
	EndIf
	WinWait("Conan Exiles -", "", 70)
Else
   Local $MEM = ProcessGetStats($PID, 0)
   If $MEM[0] > $ExMem And $ExMemRestart = "no" Then
	  FileWriteLine(@ScriptDir & "\ConanServerUtility_ExcessiveMemoryLog.txt", @MON &"-"& @MDAY &"-"& @YEAR &" "& @HOUR &":"& @MIN &" --Work Memory:"& $MEM[0] & _
        " --Peak Memory:"& $MEM[1])
	  Sleep (10000)
   ElseIf $MEM[0] > $ExMem And $ExMemRestart = "yes" Then
	  FileWriteLine(@ScriptDir & "\ConanServerUtility_RestartLog.txt", @MON &"-"& @MDAY &"-"& @YEAR &" "& @HOUR &":"& @MIN &" --Work Memory:"& $MEM[0] & _
	  " --Peak Memory:"& $MEM[1] &" Excessive Memory Use - Restart Requested by ConanServerUtility Script")
	  CloseServer()
	  Sleep (10000)
   EndIf
EndIf

If ((@HOUR = $HotHour1 Or @HOUR = $HotHour2 Or @HOUR = $HotHour3 Or @HOUR = $HotHour4 Or @HOUR = $HotHour5 Or @HOUR = $HotHour6) And @MIN = $HotMin And $RestartDaily = "yes") Then
   Local $PID = ProcessExists(""& $Server_EXE &"")
	  If $PID Then
		 Local $MEM = ProcessGetStats($PID, 0)
		 FileWriteLine(@ScriptDir & "\ConanServerUtility_RestartLog.txt", @MON &"-"& @MDAY &"-"& @YEAR &" "& @HOUR &":"& @MIN &" --Work Memory:"& $MEM[0] & _
		 " --Peak Memory:"& $MEM[1] &" Daily Restart Requested by ConanServerUtility Script")
		 CloseServer()
	  EndIf
   Sleep (10000)
EndIf

If @MIN = $HotMin And $CheckForUpdate = "yes" Then
	UpdateCheck()
	Sleep(70000)
EndIf

Sleep (500)
WEnd

 

 

Share this post


Link to post
Share on other sites
8 hours ago, Dateranoth said:

V2.2.1.0 Update!

This is a feature release. It adds two options to the INI file. One is to disable using MULTIHOME to set the IP. Set BindIP=no if you are having connection issues.  Also, adds an option to close the windows that come up when running the server with steam open. This will automatically close them and continue to start the server. Set SteamFix=yes

 

V2.2.1.0 Downloads

Complete Version 2.2.1.0 including Source

Conan Server Utility V2.2.1.0

Conan Server Remote Restart Utility V2.2.1.0

Conan Server Utility V2.2.1.0 Source

Conan Server Remote Restart Utility V2.2.1.0 Source

 

V2.2.1.0 Server Utility Source:

  Reveal hidden contents


#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=favicon.ico
#AutoIt3Wrapper_Res_Comment=By Dateranoth - Feburary 5, 2017
#AutoIt3Wrapper_Res_Description=Utility for Running Conan Server
#AutoIt3Wrapper_Res_Fileversion=2.2.1.0
#AutoIt3Wrapper_Res_LegalCopyright=Dateranoth @ https://gamercide.com
#AutoIt3Wrapper_Res_Language=1033
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
;By Dateranoth - Feburary 5, 2017
;Used by https://gamercide.com on their server
;Feel free to change, adapt, and distribute

#include <Date.au3>
#include <Process.au3>
#include <MsgBoxConstants.au3>
#include <File.au3>
Opt("WinTitleMatchMode", 1) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase

;User Variables
If FileExists("ConanServerUtility.ini") Then
   Local $BindIP = IniRead("ConanServerUtility.ini", "Use MULTIHOME to Bind IP? Disable if having connection issues (yes/no)", "BindIP", "yes")
   Local $g_IP = IniRead("ConanServerUtility.ini", "Game Server IP", "ListenIP", "127.0.0.1")
   Local $GamePort = IniRead("ConanServerUtility.ini", "Game Server Port", "GamePort", "27015")
   Local $AdminPass = IniRead("ConanServerUtility.ini", "Admin Password", "AdminPass", "yOuRpaSHeRe")
   Local $MaxPlayers = IniRead("ConanServerUtility.ini", "Max Players", "MaxPlayers", "20")
   Local $serverdir = IniRead("ConanServerUtility.ini", "Server Directory. NO TRAILING SLASH", "serverdir", "C:\Game_Servers\Conan_Exiles_Server")
   Local $UseSteamCMD = IniRead("ConanServerUtility.ini", "Use SteamCMD To Update Server? yes/no", "UseSteamCMD", "yes")
   Local $steamcmddir = IniRead("ConanServerUtility.ini", "SteamCMD Directory. NO TRAILING SLASH", "steamcmddir", "C:\Game_Servers\SteamCMD")
   Local $UseRemoteRestart = IniRead("ConanServerUtility.ini", "Use Remote Restart ?yes/no", "UseRemoteRestart", "no")
   Local $g_Port = IniRead("ConanServerUtility.ini", "Remote Restart Port", "ListenPort", "57520")
   Local $RestartCode = IniRead("ConanServerUtility.ini", "Remote Restart Password", "RestartCode", "FVtb2DXgp8SYwj7J")
   Local $RestartDaily = IniRead("ConanServerUtility.ini", "Restart Server Daily? yes/no", "RestartDaily", "no")
   Local $CheckForUpdate = IniRead("ConanServerUtility.ini", "Check for Update Every Hour? yes/no", "CheckForUpdate", "yes")
   Local $HotHour1 = IniRead("ConanServerUtility.ini", "Daily Restart Hours? 00-23", "HotHour1", "00")
   Local $HotHour2 = IniRead("ConanServerUtility.ini", "Daily Restart Hours? 00-23", "HotHour2", "00")
   Local $HotHour3 = IniRead("ConanServerUtility.ini", "Daily Restart Hours? 00-23", "HotHour3", "00")
   Local $HotHour4 = IniRead("ConanServerUtility.ini", "Daily Restart Hours? 00-23", "HotHour4", "00")
   Local $HotHour5 = IniRead("ConanServerUtility.ini", "Daily Restart Hours? 00-23", "HotHour5", "00")
   Local $HotHour6 = IniRead("ConanServerUtility.ini", "Daily Restart Hours? 00-23", "HotHour6", "00")
   Local $HotMin = IniRead("ConanServerUtility.ini", "Daily Restart Minute? 00-59", "HotMin", "01")
   Local $ExMem = IniRead("ConanServerUtility.ini", "Excessive Memory Amount?", "ExMem", "6000000000")
   Local $ExMemRestart = IniRead("ConanServerUtility.ini", "Restart On Excessive Memory Use? yes/no", "ExMemRestart", "no")
   Local $SteamFix = IniRead("ConanServerUtility.ini", "Running Server with Steam Open? (yes/no)", "SteamFix", "no")
Else
   IniWrite("ConanServerUtility.ini", "Use MULTIHOME to Bind IP? Disable if having connection issues (yes/no)", "BindIP", "yes")
   IniWrite("ConanServerUtility.ini", "Game Server IP", "ListenIP", "127.0.0.1")
   IniWrite("ConanServerUtility.ini", "Game Server Port", "GamePort", "27015")
   IniWrite("ConanServerUtility.ini", "Admin Password", "AdminPass", "yOuRpaSHeRe")
   IniWrite("ConanServerUtility.ini", "Max Players", "MaxPlayers", "20")
   IniWrite("ConanServerUtility.ini", "Server Directory. NO TRAILING SLASH", "serverdir", "C:\Game_Servers\Conan_Exiles_Server")
   IniWrite("ConanServerUtility.ini", "Use SteamCMD To Update Server? yes/no", "UseSteamCMD", "yes")
   IniWrite("ConanServerUtility.ini", "SteamCMD Directory. NO TRAILING SLASH", "steamcmddir", "C:\Game_Servers\SteamCMD")
   IniWrite("ConanServerUtility.ini", "Use Remote Restart ?yes/no", "UseRemoteRestart", "no")
   IniWrite("ConanServerUtility.ini", "Remote Restart Port", "ListenPort", "57520")
   IniWrite("ConanServerUtility.ini", "Remote Restart Password", "RestartCode", "FVtb2DXgp8SYwj7J")
   IniWrite("ConanServerUtility.ini", "Restart Server Daily? yes/no", "RestartDaily", "no")
   IniWrite("ConanServerUtility.ini", "Check for Update Every Hour? yes/no", "CheckForUpdate", "yes")
   IniWrite("ConanServerUtility.ini", "Daily Restart Hours? 00-23", "HotHour1", "00")
   IniWrite("ConanServerUtility.ini", "Daily Restart Hours? 00-23", "HotHour2", "00")
   IniWrite("ConanServerUtility.ini", "Daily Restart Hours? 00-23", "HotHour3", "00")
   IniWrite("ConanServerUtility.ini", "Daily Restart Hours? 00-23", "HotHour4", "00")
   IniWrite("ConanServerUtility.ini", "Daily Restart Hours? 00-23", "HotHour5", "00")
   IniWrite("ConanServerUtility.ini", "Daily Restart Hours? 00-23", "HotHour6", "00")
   IniWrite("ConanServerUtility.ini", "Daily Restart Minute? 00-59", "HotMin", "01")
   IniWrite("ConanServerUtility.ini", "Excessive Memory Amount?", "ExMem", "6000000000")
   IniWrite("ConanServerUtility.ini", "Restart On Excessive Memory Use? yes/no", "ExMemRestart", "no")
   IniWrite("ConanServerUtility.ini", "Running Server with Steam Open? (yes/no)", "SteamFix", "no")
   MsgBox(4096, "Default INI File Made", "Please Modify Default Values and Restart Script")
   Exit
EndIf

OnAutoItExitRegister("Gamercide")

Global $sFile = ""
Global $Server_EXE = "ConanSandboxServer-Win64-Test.exe"
Func Gamercide()
	If @exitMethod <> 1 Then
	$Shutdown = MsgBox(4100, "Shut Down?","Do you wish to shutdown the server?",10)
		If $Shutdown = 6 Then
			CloseServer()
		EndIf
		MsgBox(4096, "Thanks for using our Application", "Please visit us at https://gamercide.com",5)
	EndIf
	Exit
EndFunc

Func CloseServer()
	Local $PID = ProcessExists(""& $Server_EXE &"")
	ControlSend("Conan Exiles -", "", "", "I" & @CR)
	ControlSend("Conan Exiles -", "", "", "I" & @CR)
	ControlSend("Conan Exiles -", "", "", "^C")
	WinWaitClose("Conan Exiles -", "", 60)
	If $PID Then
		ProcessClose($PID)
    EndIf
EndFunc

Func GetRSS()
	Local $oXML = ObjCreate("Microsoft.XMLHTTP")
	$oXML.Open("GET", "http://steamcommunity.com/games/440900/rss/", 0)
	$oXML.Send

	$sFile = _TempFile(@ScriptDir, '~', '.xml')
	FileWrite($sFile, $oXML.responseText)
EndFunc

Func ParseRSS()
	$sXML = $sFile
	Local $oXML = ObjCreate("Microsoft.XMLDOM")
	$oXML.Load($sXML)
	Local $oNames = $oXML.selectNodes("//rss/channel/item/title")
	Local $aMyDate, $aMyTime
	_DateTimeSplit(_NowCalc(), $aMyDate, $aMyTime)
    Local $cDate = "PATCH "& StringFormat("%02d", $aMyDate[3]) &"."& StringFormat("%02d", $aMyDate[2]) &"."& StringFormat("%04d", $aMyDate[1])
	Local $cFile = @ScriptDir &"\ConanServerUtility_LastUpdate.txt"
	For $oName In $oNames

		If StringRegExp($oName.text,$cDate&"(?i)") Then
				If FileRead($cFile) = $oName.text Then
					;ConsoleWrite("No New Update" & @CRLF)
					ExitLoop
				Else
					FileDelete($cFile)
					FileWrite($cFile,$oName.text)
					Local $PID = ProcessExists(""& $Server_EXE &"")
					If $PID Then
						FileWriteLine(@ScriptDir & "\ConanServerUtility_RestartLog.txt", @MON &"-"& @MDAY &"-"& @YEAR &" "& @HOUR &":"& @MIN &" ["& $oName.text &"] Daily Restart Requested by ConanServerUtility Script")
						CloseServer()
					EndIf
					ExitLoop
				EndIf
		EndIf
	Next
EndFunc

Func UpdateCheck()
	GetRSS()
	ParseRSS()
	FileDelete($sFile)
EndFunc

Func _TCP_Server_ClientIP($hSocket)
   Local $pSocketAddress, $aReturn
   $pSocketAddress = DllStructCreate("short;ushort;uint;char[8]")
   $aReturn = DllCall("ws2_32.dll", "int", "getpeername", "int", $hSocket, "ptr", DllStructGetPtr($pSocketAddress), "int*", DllStructGetSize($pSocketAddress))
   If @error Or $aReturn[0] <> 0 Then Return $hSocket
	  $aReturn = DllCall("ws2_32.dll", "str", "inet_ntoa", "int", DllStructGetData($pSocketAddress, 3))
   If @error Then Return $hSocket
	  $pSocketAddress = 0
   Return $aReturn[0]
EndFunc ;==>_TCP_Server_ClientIP

If $UseSteamCMD = "yes" Then
	Local $sFileExists = FileExists($steamcmddir &"\steamcmd.exe")
	If $sFileExists = 0 Then
		MsgBox ( 0x0, "SteamCMD Not Found", "Could not find steamcmd.exe at "& $steamcmddir)
		Exit
	EndIf

Else
	Local $cFileExists = FileExists($serverdir &"\ConanSandboxServer.exe")
	If $cFileExists = 0 Then
		MsgBox ( 0x0, "Conan Server Not Found", "Could not find ConanSandboxServer.exe at "& $serverdir)
		Exit
	EndIf
Endif


If $UseRemoteRestart = "yes" Then
; Start The TCP Services
TCPStartup()
Local $MainSocket = TCPListen($g_IP, $g_Port, 100)
	If $MainSocket = -1 Then
		MsgBox ( 0x0, "TCP Error", "Could not bind to [" &  $g_IP & "] Is this the correct Server IP?")
		Exit
		EndIf
EndIf

While True
If $UseRemoteRestart = "yes" Then
Local $ConnectedSocket = TCPAccept($MainSocket)
If $ConnectedSocket >= 0 Then
$Count = 0
While $Count < 30
$RECV = TCPRecv($ConnectedSocket,512)
   If $RECV = $RestartCode Then
	  Local $PID = ProcessExists(""& $Server_EXE &"") ; Will return the PID or 0 if the process isn't found.
	  If $PID Then
		 Local $IP = _TCP_Server_ClientIP($ConnectedSocket)
		 Local $MEM = ProcessGetStats($PID, 0)
		 FileWriteLine(@ScriptDir & "\ConanServerUtility_RestartLog.txt", @MON &"-"& @MDAY &"-"& @YEAR &" "& @HOUR &":"& @MIN &" --Work Memory:"& $MEM[0] & _
		 " --Peak Memory:"& $MEM[1] &" Restart Requested by Remote Host: "& $IP)
		 CloseServer()
		 Sleep (10000)
		 ExitLoop
	  EndIf
	  Else
	    Local $IP = _TCP_Server_ClientIP($ConnectedSocket)
		FileWriteLine(@ScriptDir & "\ConanServerUtility_RestartLog.txt", @MON &"-"& @MDAY &"-"& @YEAR &" "& @HOUR &":"& @MIN &" Restart ATTEMPT by Remote Host: "& $IP &" WRONG PASSWORD")
		ExitLoop
   EndIf
$Count += 1
Sleep (1000)
WEnd
If $ConnectedSocket <> -1 Then TCPCloseSocket($ConnectedSocket)
EndIf
EndIf


Local $PID = ProcessExists(""& $Server_EXE &"")
If $PID = 0 Then
	If $UseSteamCMD = "yes" Then
		RunWait(""& $steamcmddir &"\steamcmd.exe +@ShutdownOnFailedCommand 1 +@NoPromptForPassword 1 +login anonymous +force_install_dir "& $serverdir &" +app_update 443030 validate +quit")
	EndIf
	If $CheckForUpdate = "yes" Then
		UpdateCheck()
	EndIf
	If $BindIP = "no" Then
		Run(""& $serverdir &"\ConanSandbox\Binaries\Win64\"& $Server_EXE &" ConanSandBox?QueryPort="& $GamePort &"?MaxPlayers="& $MaxPlayers &"?AdminPassword="& $AdminPass &"?listen -nosteamclient -game -server -log")
	Else
		Run(""& $serverdir &"\ConanSandbox\Binaries\Win64\ConanSandboxServer-Win64-Test.exe ConanSandBox?MULTIHOME="& $g_IP &"?QueryPort="& $GamePort &"?MaxPlayers="& $MaxPlayers &"?AdminPassword="& $AdminPass &"?listen -nosteamclient -game -server -log")
	EndIf
	If $SteamFix = "yes" Then
		WinWait(""& $Server_EXE &" - Entry Point Not Found","",5)
		If WinExists(""& $Server_EXE &" - Entry Point Not Found") Then
			ControlSend(""& $Server_EXE &" - Entry Point Not Found", "", "", "{enter}")
		EndIf
		WinWait(""& $Server_EXE &" - Entry Point Not Found","",5)
		If WinExists(""& $Server_EXE &" - Entry Point Not Found") Then
			ControlSend(""& $Server_EXE &" - Entry Point Not Found", "", "", "{enter}")
		EndIf
	EndIf
	WinWait("Conan Exiles -", "", 70)
Else
   Local $MEM = ProcessGetStats($PID, 0)
   If $MEM[0] > $ExMem And $ExMemRestart = "no" Then
	  FileWriteLine(@ScriptDir & "\ConanServerUtility_ExcessiveMemoryLog.txt", @MON &"-"& @MDAY &"-"& @YEAR &" "& @HOUR &":"& @MIN &" --Work Memory:"& $MEM[0] & _
        " --Peak Memory:"& $MEM[1])
	  Sleep (10000)
   ElseIf $MEM[0] > $ExMem And $ExMemRestart = "yes" Then
	  FileWriteLine(@ScriptDir & "\ConanServerUtility_RestartLog.txt", @MON &"-"& @MDAY &"-"& @YEAR &" "& @HOUR &":"& @MIN &" --Work Memory:"& $MEM[0] & _
	  " --Peak Memory:"& $MEM[1] &" Excessive Memory Use - Restart Requested by ConanServerUtility Script")
	  CloseServer()
	  Sleep (10000)
   EndIf
EndIf

If ((@HOUR = $HotHour1 Or @HOUR = $HotHour2 Or @HOUR = $HotHour3 Or @HOUR = $HotHour4 Or @HOUR = $HotHour5 Or @HOUR = $HotHour6) And @MIN = $HotMin And $RestartDaily = "yes") Then
   Local $PID = ProcessExists(""& $Server_EXE &"")
	  If $PID Then
		 Local $MEM = ProcessGetStats($PID, 0)
		 FileWriteLine(@ScriptDir & "\ConanServerUtility_RestartLog.txt", @MON &"-"& @MDAY &"-"& @YEAR &" "& @HOUR &":"& @MIN &" --Work Memory:"& $MEM[0] & _
		 " --Peak Memory:"& $MEM[1] &" Daily Restart Requested by ConanServerUtility Script")
		 CloseServer()
	  EndIf
   Sleep (10000)
EndIf

If @MIN = $HotMin And $CheckForUpdate = "yes" Then
	UpdateCheck()
	Sleep(70000)
EndIf

Sleep (500)
WEnd

 

 

Hey date, thanks for the hard work so far! However it seems i cannot run the utility as it persists to give me the "Could not bind to (x.x.x.x) is this the correct server ip" I have tried disabling 'Bind ip' and it still persists to give me this error. I have tried my external ip, and of course as you said my local ip.  

Share this post


Link to post
Share on other sites
1 minute ago, Dateranoth said:

Can you PM me your INI file? Remove the passwords. You can probably get by by disabling remote start for now. The remote server restart option is what does the check.

 

Jesus fast answer mate!! Ill send it to you right away

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

  • Recently Browsing   0 members

    No registered users viewing this page.

×