Automatic Update Script – Updated on 08/15/2015

To the pleasure of its fans, ARK has a really short update interval. This can however be infuriating for server administrators, so we set out to make your life a little bit easier: This script will automatically check whether there is a new update version, and in case there is, automatically update your server. The script is written in PowerShell (version 3 required). It will also inform your players before the update so that they can secure their stuff and log off in a safe location.

Requirements

Installation

Save this text as update.cmd

[sourcecode toolbar=”true” language=”plain” title=”update.cmd”]
@echo off
ver | find "2003" > nul
if %ERRORLEVEL% == 0 goto ver_2003

if not exist "%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe" goto install

"%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe" -command "exit $PSVersionTable.PSVersion.Major"
set PSVer=%ERRORLEVEL%
if %PSVer% LSS 3 goto ps1

powershell -ExecutionPolicy unrestricted -File "%~dp0mainscript.ps1"

exit

:ps1
echo Powershell 2 is not supported.
pause
exit

:ver_2003
echo Windows 2003 is not supported.
pause
exit

:install
echo PowerShell is not installed
pause
exit
[/sourcecode]

 

Save this text as mainscript.ps1

[sourcecode toolbar=”true” language=”powershell” title=”mainscript.ps1″]
$steamcmdFolder="C:\steamcmd"
$arksurvivalFolder="C:\arkserver"
$arksurvivalSteamScript="update_ark.txt"
$rconIP="127.0.0.1"
$rconPort=32330
$rconPassword="YOURPASSWORD"
$arkSurvivalStartArguments=$("TheIsland?QueryPort=27015?Port=7777?SetCheatPlayer=True?RCONEnabled=True?RCONPort="+$rconPort+"?listen")
$mcrconExec="C:\ARK-Scripts\mcrcon.exe"
$steamAppID="376030"
# Without clearing cache app_info_update may return old informations!
$clearCache=1

$scriptPath = Split-Path -parent $MyInvocation.MyCommand.Definition
$dataPath = $scriptPath+"\data"
$steamcmdExec = $steamcmdFolder+"\steamcmd.exe"
$steamcmdCache = $steamcmdFolder+"\appcache"
$latestAppInfo = $dataPath+"\latestappinfo.json"
$updateinprogress = $arksurvivalFolder+"\updateinprogress.dat"
$latestAvailableUpdate = $dataPath+"\latestavailableupdate.txt"
$latestInstalledUpdate = $dataPath+"\latestinstalledupdate.txt"
If (Test-Path $updateinprogress) {
Write-Host Update is already in progress
} Else {
Get-Date | Out-File $updateinprogress
Write-Host Creating data Directory
New-Item -Force -ItemType directory -Path $dataPath
If ($clearCache) {
Write-Host Removing Cache Folder
Remove-Item $steamcmdCache -Force -Recurse
}
Write-Host Checking for an update
& $steamcmdExec +login anonymous +app_info_update 1 +app_info_print $steamAppID +app_info_print $steamAppID +quit | Out-File $latestAppInfo
Get-Content $latestAppInfo -RAW | Select-String -pattern ‘(?m)"public"\s*\{\s*"buildid"\s*"\d{6,}"’ -AllMatches | %{$_.matches[0].value} | Select-String -pattern ‘\d{6,}’ -AllMatches | %{$_.matches} | %{$_.value} | Out-File $latestAvailableUpdate
If (Test-Path $latestInstalledUpdate) {
$installedVersion = Get-Content $latestInstalledUpdate
} Else {
$installedVersion = 0
}
$availableVersion = Get-Content $latestAvailableUpdate
if ($installedVersion -ne $availableVersion) {
Write-Host Update Available
Write-Host Installed build: $installedVersion – available build: $availableVersion
& $mcrconExec -c -H $rconIP -P $rconPort -p $rconPassword "broadcast New update available, server is restarting in 10 minutes!"
Start-Sleep -s 300
& $mcrconExec -c -H $rconIP -P $rconPort -p $rconPassword "broadcast New update available, server is restarting in 5 minutes!"
Start-Sleep -s 240
& $mcrconExec -c -H $rconIP -P $rconPort -p $rconPassword "broadcast New update available, server is restarting in 1 minute!"
Start-Sleep -s 60
& $mcrconExec -c -H $rconIP -P $rconPort -p $rconPassword "broadcast New update available, server is restarting!"
& $mcrconExec -c -H $rconIP -P $rconPort -p $rconPassword "saveworld"
Start-Sleep -s 10
#Does not work atm
# & $mcrconExec -c -H $rconIP -P $rconPort -p $rconPassword "quit"
$pidARK = (Wmic process where "Commandline like ‘%$rconPort%’ and Name=’ShooterGameServer.exe’" get ProcessId | findstr /r "[1-9][0-9]")
& taskkill /PID $pidARK
Start-Sleep -s 20
& $steamcmdExec +runscript $arksurvivalSteamScript
& $arksurvivalFolder"\ShooterGame\Binaries\Win64\ShooterGameServer.exe" $arkSurvivalStartArguments -nosteamclient -game -lowmemory -nosound -sm4 -server -log
$availableVersion | Out-File $latestInstalledUpdate
Write-Host Update Done!
}
Remove-Item $updateinprogress -Force
}
[/sourcecode]

This is an example of my steamscript (put this in the steamcmd root folder):

[sourcecode toolbar=”true” language=”plain” title=”update_ark.txt”]

//ark
@ShutdownOnFailedCommand 1
@NoPromptForPassword 1
nSubscribedAutoDownloadMaxSimultaneous 32
@cMaxContentServersToRequest 16
@cMaxInitialDownloadSources 1
@fMinDataRateToAttemptTwoConnectionsMbps 0.01
@fDownloadRateImprovementToAddAnotherConnection 0.01
login anonymous
force_install_dir C:\arkserver\
app_update 376030
// validate
quit[/sourcecode]

How to use it?

Edit the variables of mainscript.ps1 so that it fits to your environment.

To run it in an interval just use the Windows Task Scheduler and bind the update.cmd to it.

 

Hope we could help you with the automatic update script for windows!

About the author

94 thoughts on “Automatic Update Script – Updated on 08/15/2015”

  1. What is the $arksurvivalSteamScript=”update_ark-pve.txt”?
    My server runs on a PvP schedule. Wich means it’s PvP only between 18 and 21 at evening. Rest of the time is PvE. How to I implement this feature into this script?

    I’m using a program called System Scheduler Professional, to execute all my scheduled commands. Currently I’m simply running my own version of an update script. It’ll update no matter if there is one. Ergo verify files. So this is def. needed here ^^

  2. Okay so I’ve tried most things now. Pretty sure I named everything the right things. Still just get a quick black box that I can’t catch with with print screen then nothing happens.

          1. The path to powershell is correct and its installed, it opens an installer for an online casino…

          2. Ohm a Virus?
            Thats what it looks like to me. Which Os Version are you using

          3. powershell -ExecutionPolicy unrestricted -File “%~dp0mainscript.ps1″
            thats what was loading in the installer….
            i changed it to where my update.ps1 script is (your mainscript.ps1)

            Getting this error now:
            Get-Content : Cannot find path ‘E:\ARKSurvivalEvolved\autoupdate_script\data\latestinstalledupdate.txt’
            because it does not exist.
            At E:\ARKSurvivalEvolved\autoupdate_script\update.ps1:33 char:21

            Seems that your thing should be writing this file somewhere, but it must happen after this check.

          4. oh that rly happens in a new environment, should be fixed with the new mainscript.ps1 🙂
            but my powershell script cant definitely not open casino stuff sites 😀
            and mainscript.ps1 is working fine for me

          5. Getting the last updated value is working now, Theres a prob with the REGX you have posted it uses ” instead of ” changed that and it returns the correct version number

        1. Well I think i have it working

          I’ve deleted most of the code in the update.cmd to just:
          powershell -ExecutionPolicy unrestricted -File “E:\ARKSurvivalEvolved\autoupdate_script\update.ps1”

          Everythings working fine now i had to create the initial .txt files in the data directory.

          At least server messages are broadcasting, have to wait to see if how the actual updating goes, once an update is released

          1. Its not writing any values to the last updated and currerentversion files.

            I dont think that reg ex you have is pulling anything out.

            would be better if you could strip the response and get just the json data without all the extra steam connection stuff

            I’m not sure quite how to do that

  3. So do you think this would run ok if I set it up with our current Firedaemon, which would turn the script into a service? Right now we run ark as a service through firedaemon and it basically takes care of everything if the server ever crashes. We have the update script ran as a pre-cursor to starting the server, but right now it takes an admin to saveworld and quit to start the updates.

    I am hoping I can use your script with Firedaemon basically so that I get the automatic updating feature without losing the “if my server were to crash because its alpha lol” it stays up.

    1. i think it should work if use the same windows user for that service. But i have never used firedeamon before. Cant tell for sure 😉

      1. It’s pretty nifty software. Basically, I would just turn your script into a windows service that would just automatically restart if it ever crashed. From what I’ve seen with your script, It takes care of everything else. And it all would run under the administrative user on my vds.

  4. nice script but how can i use it when i rent a server from a hoster? in my case g-portal.com.

    i dont think they use steam cmd or maybe i dont know. would love to use this script but dont know how. can you do a tutorial for server like this? where you have to edit configs @ your ftp

  5. Would be great if the script created a back-up of the data in case an update comes with breaking changes that affects the data (like missing items). I think it may not be that hard to do, I guess it would be copying files into a directory, but I’m not sure how ARK servers work though.

  6. When I get the script to pause now and actually show me what’s going on. Took me about 24 hours to get to here. It’s just saying “PowerShell is not installed” but when I try to go install it again, it just says that “Update was not installed”. Not really sure what’s going on here anymore. Sorry to say.

  7. Trying to get this script to work, once I launch the update.cmd it opens up the mainscript.ps1 and nothing more, then if I open up the .ps1 file in PowerShell and run it it says “Update is already in progress” and then nothing happens.

    Also, I’m currently using a watchdog-script that will notice if the server crashes and will launch it if it’s down, am I suppose to use that script as the “steamscript”, or is that only for the server update info?

    Great release btw, been waiting for this!

      1. I had a few problems like yours:

        I’ve fixed most the problems in the script (there’s no longer a check to see if powershell 3 is installed. and it works without needing any extra scripts).

        The other problem i found was that the Quit server command does not exit the server so when after the server had updated it just created another server with the same settings, as the server is never actually shut down!

        My script fixes that by killing the ShooterGameServer process, so its actually shut down.
        You can download it from my drop box rename it to whatever.ps1

        Right click it and choose edit, it should open in powershell:
        Change all the settings marked #CHANGE ME –

        You can run it in powershell first to check it works.

        Then set it up in task manager to run every hr.
        The file is at the following link
        https://dl.dropboxusercontent.com/u/5769149/ark_server_updater.txt

          1. Go to your task manager and click processes (while the server is running)

            You should see ShooterGameServer in the list
            that’s the process that needs to be shutdown, can you see that in the processes list?

            Are there any errors generated by the script?

        1. Thank You so much for this! Got it working, but the only problem now is that the script won’t kill the current task that runs the server. I get this message:
          http://i.imgur.com/FzFPJYT.png

          Also a minor problem is one of the variables that shows the current version in one of those automatic announces. “$currentVersion” doesnt seem to work, it’s just blank ingame. 🙂

          1. For your script dizzy, instead of killing the actual process, there is a quit command that exists. Remote rcon does not work with cheat quit, but u can send a kill command, something like DoExit()

            Ill look it up later when I get home, but I know the Arkon software implements it differently for remote users.

        2. Have ARK changed how the info looks about build nr is showen ?
          The command do not give any build nr anymore

          & $steamcmdExec +login anonymous +app_info_update 1 +app_info_print $steamAppID +quit | Out-File $latestAppInfo
          Get-Content $latestAppInfo -RAW | Select-String -pattern ‘(?m)”public”\s*\{\s*”buildid”\s*”\d{6,}”‘ -AllMatches | %{$_.matches[0].value} | Select-String -pattern ‘\d{6,}’ -AllMatches | %{$_.matches} | %{$_.value} | Out-File $latestAvailableUpdate

          it do not grab any build nr anymore

          1. Seems there’s a character that’s being interpreted incorrectly when I downloaded your file… for line:

            Get-Content $latestAppInfo -RAW | Select-String -pattern ‘(?m)”public”\s*\{\s*”buildid”\s*”\d{6,}”‘ -AllMatches | %{$_.matches[0].value} | Select-String -pattern ‘\d{6,}’ -AllMatches | %{$_.matches} | %{$_.value} | Out-File $latestAvailableUpdate

            the powershell window shows that it is seeing the ‘ character (forward and backward single quotes) in ‘\d{6,}’ as the lower case a with a caret over it and doesn’t know what to do with it. What should those characters be?

            There are a few other errors but I don’t know if they are being caused by this one or not so I want to fix this one first.

        3. Hi Dizzy,

          Was just wondering if this was going to get updated, for some reason it is always returning a $latestAvailableUpdate of nothing.
          Secondly I was wondering if you had a place to donate? I’d love to support the development of this utility.

    1. you need to check the data directory and make sure updateinprogress.dat is deleted,
      if this file exists it thinks the update is already in progress and skips everything.

    1. yeah but it works best if you set up a cmd file that runs the script every hour, its much easier than using task manager, and the benefit it allows you to see the script running in the the cmd window

      1. Hey Dizzy, first off – great utility, I love it. but I am confused when you say set up a cmd file to see it run? I have just used task scheduler to execute the script every hour, but I can’t see output. The reason I ran it with task scheduler is so that I never have to touch the dedi box, the server runs at startup, with nightly reboots, all automatic. Any idea how I can get the task scheduler to show output?

        1. a cmd file is just a simple text file with the .bat extension

          my one looks like this:
          @ECHO OFF
          :START
          CLS
          ECHO ARK Server Auto Update and MOTD Script
          ECHO.
          powershell.exe -file E:\ARKSurvivalEvolved\autoupdate_script\update_test.ps1 cd “E:\ARKSurvivalEvolved\autoupdate_script\”
          ECHO
          ECHO.

          GOTO START

          It basically runs the cmd script as its at a cmd prompt you’ll also see the output so you know its working.

          once the powershell script finishes, it just runs it right again, so either updates or sends the MOTD messages instead

          it will keep looping until its closed.

          1. you can set that cmd file to run when the server starts with task scheduler, but again you won’t see the process window, that’s the caveat with task scheduler

      1. Hi Bob, If you use the .ps1 from Dizzy’s drop box, yes – it works great just make sure you change all the variables to represent your sever.

  8. Hey man, love the concept of the script but can’t get it to work. It launches the steamcmd but just comes up with “Current version: 0 – Latest version: 725628”

    Placed steamcmd in a folder, “D:\Ark” and had it download the server/steam files there (D:\Ark\bin, D:\Ark\steamapps, etc) and use the following:

    $steamcmdFolder=”D:\Ark”
    $arksurvivalFolder=”D:\Ark\steamapps\common”

    Do I have that wrong?

    1. Hi Dizzy,

      Thanks for your great script but i have only one little problem. $currentVersion dont give any output. Do you have any suggestions how to fix this.

      Thanks!

      1. I’ve actually just realized mine does the same, I wonder if this will actually work as intended, or if I do not have it pointing to the right folder path. My ShooterGameServer.exe is located at C:\ArkServer\Servers\ShooterGame\Binaries\Win64
        so I pointed the variable at
        $arksurvivalFolder=”C:\ArkServer\Servers” I hope this is correct. I guess we’ll see tonight once 196 launches tonight…

        1. so it seems like this line;

          & $steamcmdExec +login anonymous +app_info_update 1 +app_info_print $steamAppID +quit | Out-File $latestAppInfo

          isn’t actually printing all the the info that you’d get if you manually ran the app_info_print command from steamCMD, only part of it. I believe this might be causing the issue but I haven’t found a way to fix it yet.

          1. Did have the same problem did find some info on this web page “https://steamdb.info/forum/362/” about grabing buildid and from the command (csgo) ./steamcmd.sh +login anonymous +app_info_update 1 +app_info_print “740” +app_info_print “740” +quit

            i did change my line to:
            & $steamcmdExec +login anonymous +app_info_update 1 +app_info_print $steamAppID +app_info_print $steamAppID +quit | Out-File $latestAppInfo

            I have no idea what i am doing but it do look like it works now and it grabs the build id now from the line:
            PS C:\server files\ark\scripts> Get-Content $latestAppInfo -RAW | Select-String -pattern ‘(?m)”public”\s*\{\s*”buildid”\s*”\d{6,}”‘ -AllMatches | %{$_.matches[0].value} | Select-String -pattern ‘\d{6,}’ -AllMatches | %{$_.matches} | %{$_.value}
            725628

      1. think you have uploaded the wrong file to the dropbox or you have posted wrong link.
        For me i am getting to “Voice Attack Conditions Tutorials.zip”
        Was going to check out your .bat file.

  9. Thanks a ton Blackhawk, it worked, I however did notice that the $latestInstalledUpdate was never updating, so I threw this line into the bottom after everything completed;
    $availableVersion | Out-File $latestInstalledUpdate – which will just keep the txt filed up to date… I hope- trying to get this fully automated is not as easy as I thought.

    1. I did have same problem from the start with the latest version file. I can’t remember now what I did change (il check later). I have allsow added a extra script so will be run before a upgrade so do copy the ark/world before an update and create a folder with timestamps.
      And I do use a cmd file so runs with task manager every 1 hour for starting the upgrade script.
      Dizzy, jacke or any one else if you want to talk about the script/ark I am to be found from time to time at teamspeak server ts.libcall.eu.

      1. Yeah I have one set up to do the same, I also changed the line; $ArkSurvivalStartArguemnts to use Get-Content from my run_arkserver.bat so that I don’ have to update the script whenever I change something in the .bat.

        One other thing I’ve noticed is more often that not it is never able to delete the updateinprogress.dat. as A resolution I’ve just commented out that if statement as it does a logical check of version numbers prior to updating anyways, and if it is already the most current version it will just end the script.

  10. I am having trouble here…Yahoo!

    When I run the update cmd file it starts up cmd and goes through steam login which it said was successful….. then it can find the server but the server gives no response!

    I am running the server off a home PC and using this auto update on same said pc.

    Questions are:

    1. Do you know why server wont give a response? The server IP that I set in this script is 192.168.1.7 I tooled around and changed it to 192.168.1.32 and it couldn’t find the server at all so I am positive that the 192.168.1.7 is correct.

    2. Do I have to edit the mcrcon file at all? If so what values and which one?

    Any response would make my day for sure! Thanks everyone!

  11. I’m getting through it. I tried to do the update logging in with my username and password but it failed – probably because Steam wasn’t running so I’m switching back to an anonymous login in steamcmd. But I do notice that in the line that checks for the update (around line 51) it fails if I have the comma after the 6.

    It fails with this line. Note the comma after the 6
    Get-Content $latestAppInfo -RAW | Select-String -pattern “(?m)”public”\s*\{\s*”buildid”\s*”\d{6,}”” -AllMatches | %{$_.matches[0].value} | Select-String -pattern “\d{6,}”™ -AllMatches | %{$_.matches} | %{$_.value} | Out-File $latestAvailableUpdate

    This one works. I removed the comma after the 6,
    Get-Content $latestAppInfo -RAW | Select-String -pattern “(?m)”public”\s*\{\s*”buildid”\s*”\d{6}”” -AllMatches | %{$_.matches[0].value} | Select-String -pattern “\d{6,}”™ -AllMatches | %{$_.matches} | %{$_.value} | Out-File $latestAvailableUpdate

    So what is the purpose of the comma? With it in there, ISE shows a Missing expression after ‘,’

  12. The script is not working any more for me!
    This line seems broken:
    $steamcmdExec +login anonymous +app_info_update 1 +app_info_print $steamAppID +app_info_print $steamAppID +quit | Out-File $latestAppInfo

    The created file does not hold the output of the app_info_print command any more.
    Looks like a problem/change on steamcmd.

    1. LouPoh, I’ve been having the same issue. If you watch Task Manager when it calls steamcmd, steamcmd is crashing. You’ll see SteamErrorReporter.exe running and 90% of the time in the steamcmd/dump folder you’ll see crashdumps from steamcmd.exe

      The weird thing is, if you launch steamcmd normally it works just fine. it only crashes when another program tries to execute steamcmd. I tried with a Python script as well and I’m getting the same results, steamcmd.exe crashing.

      1. I found a solution!

        Instead of “+app_info_print $steamAppID +app_info_print $steamAppID” you have to use “+app_info_print $steamAppID +app_info_print $steamAppID +app_info_print $steamAppID +app_info_print $steamAppID”!

        So basically just double again the, already doubled command(+app_info_print $steamAppID), and it then magically works(!), but please dont ask me why or how long it took me to find this out. lol

        Hope that helps.

          1. I wonder if this is related to the issue I have been having? Basically, the server update script works fine for a few days, then one day it will quit. I have to go into the data folder and delete latestinstalledupdate.txt and then run the script again. Without that file, it forces the update. Or maybe this is a different issue all together and someone else has a fix for it. 😛

        1. I tried this and the script worked without me having to delete thelatestinstalledupdate.txt file like I have been having to do in order to get it to update. I will let it go for about a week or two and stop back to let you know the progress. Here’s hoping for the best!

          1. It’s been about a week and a half since I added that line to the script. Everything has been working great ever since. Thank you!!!

  13. This script stoped working for me to i have no idea about powershell but if anybody can edit the script so it works by grabing version number from webpage”http://arkdedicated.com/version”
    I am thinking this command can be a good start
    $URI = “http://arkdedicated.com/version”
    $HTML = Invoke-WebRequest -Uri $URI
    $HTML.content |out-file $latestAppInfo
    and it will print the version number to file atm “231.0”
    Then edit it so script shows the version number all understand and not the XXXXX number so steamcmd did list. ( broken atm)

    1. There are some people who commented on this topic who get the script to work again (perhaps this will work for you)- we try to reach Mahagon, if he can fix the auto-update Script.

  14. This updater has a fatal flaw in it that will break it should the update fail for any reason.

    The updater should not be checking a text file it created for the current installed version, it should be checking the Ark/steamapps folder and reading the app manifest for the correct current version of ark.

    It should be checking ArkInstallFolder/steamapps/appmanifest_376030.acf for buildid like it does from the steamcmd json it downloads. I am terrible with regex or I would fix it myself.

    1. The command would be
      Get-Content $GameDataManifest -RAW | Select-String -pattern ‘(?m)”buildid”\s*”\d{6,}”‘ -AllMatches | %{$_.matches[0].value} | Select-String -pattern ‘\d{6,}’ -AllMatches | %{$_.matches} | %{$_.value}

      $GameDataManifest would be defined to the location of the .acf file.

  15. just leave it here.

    if((Test-Path “D:\ARKserver\SteamCMD”) -eq $false) {
    New-Item -Path “D:\ARKserver\SteamCMD” -ItemType “directory”
    $url = “https://steamcdn-a.akamaihd.net/client/installer/steamcmd.zip”
    $output = “D:\ARKserver\SteamCMD\steamcmd.zip”
    $start_time = Get-Date
    Invoke-WebRequest -Uri $url -OutFile $output
    Write-Output “Time taken: $((Get-Date).Subtract($start_time).Seconds) second(s)”
    unzip “$output” “D:\ARKserver\SteamCMD”
    remove-item “D:\ARKserver\SteamCMD\steamcmd.zip” -Recurse
    }

    function unzip ($archive, $destination) {
    $shell = new-object -com shell.application
    $zip = $shell.NameSpace($archive)
    foreach($item in $zip.items()) {
    $shell.Namespace($destination).copyhere($item)
    }
    }

  16. Hmmm it really dosen’t seem to work…

    I am putting it up agianst a server launched with Ark Manager, why because i have never gotten the Ark Manager software to automatic update the server if there is a update to the game…

    So i have powershell, can start it by the command prompt…
    got mrcron installed and move to the ark folder
    have created the update.cmd

    my script
    @echo off
    ver | find “2003” > nul
    if %ERRORLEVEL% == 0 goto ver_2003

    if not exist “%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe” goto install

    “%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe” -command “exit $PSVersionTable.PSVersion.Major”
    set PSVer=%ERRORLEVEL%
    if %PSVer% LSS 3 goto ps1

    powershell -ExecutionPolicy unrestricted -File “%~dp0mainscript.ps1″

    exit

    :ps1
    echo Powershell 2 is not supported.
    pause
    exit

    :ver_2003
    echo Windows 2003 is not supported.
    pause
    exit

    :install
    echo PowerShell is not installed
    pause
    exit

    and the mainscript.ps1
    $steamcmdFolder=”C:\Ark Manager\steamcmd”
    $arksurvivalFolder=”C:\Ark Manager\steamcmd\Servers”
    $arksurvivalSteamScript=”update_ark.txt”
    $rconIP=”127.0.0.1″
    $rconPort=32330
    $rconPassword=”This password is hidden”
    $arkSurvivalStartArguments=$(“TheIsland?QueryPort=27015?Port=7777?SetCheatPlayer=True?RCONEnabled=True?RCONPort=”+$rconPort+”?listen”)
    $mcrconExec=”C:\Ark Manager\mrcron\mcrcon.exe”
    $steamAppID=”376030″
    # Without clearing cache app_info_update may return old informations!
    $clearCache=1

    $scriptPath = Split-Path -parent $MyInvocation.MyCommand.Definition
    $dataPath = $scriptPath+”\data”
    $steamcmdExec = $steamcmdFolder+”\steamcmd.exe”
    $steamcmdCache = $steamcmdFolder+”\appcache”
    $latestAppInfo = $dataPath+”\latestappinfo.json”
    $updateinprogress = $arksurvivalFolder+”\updateinprogress.dat”
    $latestAvailableUpdate = $dataPath+”\latestavailableupdate.txt”
    $latestInstalledUpdate = $dataPath+”\latestinstalledupdate.txt”
    If (Test-Path $updateinprogress) {
    Write-Host Update is already in progress
    } Else {
    Get-Date | Out-File $updateinprogress
    Write-Host Creating data Directory
    New-Item -Force -ItemType directory -Path $dataPath
    If ($clearCache) {
    Write-Host Removing Cache Folder
    Remove-Item $steamcmdCache -Force -Recurse
    }
    Write-Host Checking for an update
    & $steamcmdExec +login anonymous +app_info_update 1 +app_info_print $steamAppID +app_info_print $steamAppID +quit | Out-File $latestAppInfo
    Get-Content $latestAppInfo -RAW | Select-String -pattern ‘(?m)”public”\s*\{\s*”buildid”\s*”\d{6,}”‘ -AllMatches | %{$_.matches[0].value} | Select-String -pattern ‘\d{6,}’ -AllMatches | %{$_.matches} | %{$_.value} | Out-File $latestAvailableUpdate
    If (Test-Path $latestInstalledUpdate) {
    $installedVersion = Get-Content $latestInstalledUpdate
    } Else {
    $installedVersion = 0
    }
    $availableVersion = Get-Content $latestAvailableUpdate
    if ($installedVersion -ne $availableVersion) {
    Write-Host Update Available
    Write-Host Installed build: $installedVersion – available build: $availableVersion
    & $mcrconExec -c -H $rconIP -P $rconPort -p $rconPassword “broadcast New update available, server is restarting in 10 minutes!”
    Start-Sleep -s 300
    & $mcrconExec -c -H $rconIP -P $rconPort -p $rconPassword “broadcast New update available, server is restarting in 5 minutes!”
    Start-Sleep -s 240
    & $mcrconExec -c -H $rconIP -P $rconPort -p $rconPassword “broadcast New update available, server is restarting in 1 minute!”
    Start-Sleep -s 60
    & $mcrconExec -c -H $rconIP -P $rconPort -p $rconPassword “broadcast New update available, server is restarting!”
    & $mcrconExec -c -H $rconIP -P $rconPort -p $rconPassword “saveworld”
    Start-Sleep -s 10
    #Does not work atm
    # & $mcrconExec -c -H $rconIP -P $rconPort -p $rconPassword “quit”
    $pidARK = (Wmic process where “Commandline like ‘%$rconPort%’ and Name=’ShooterGameServer.exe'” get ProcessId | findstr /r “[1-9][0-9]”)
    & taskkill /PID $pidARK
    Start-Sleep -s 20
    & $steamcmdExec +runscript $arksurvivalSteamScript
    & $arksurvivalFolder”\ShooterGame\Binaries\Win64\ShooterGameServer.exe” $arkSurvivalStartArguments -nosteamclient -game -lowmemory -nosound -sm4 -server -log
    $availableVersion | Out-File $latestInstalledUpdate
    Write-Host Update Done!
    }
    Remove-Item $updateinprogress -Force
    }

    and i have put it in the windows task manager to run every 15 minute, right now the server is 239.2 and Ark Manager informs me there is a 239.3 online, so i just waited for 30 minutes and nothing happends?

    it don’t update even that there is a update? what have i done wrong?

  17. I finally have it running error-free but it isn’t working as advertised. First, it doesn’t kill the current process. An earlier post said we’d see a process called ShooterGameServer but I only see ShooterGame. When I change the script to kill ShooterGame, it says no such process, so I put it back to ShooterGameServer.

    Second, it tells me that there’s an update already in progress. It put a json file and a text file in the data directory but no .dat file. I tried deleting those two files and it still says update is already in progress and it didn’t recreate those two files.

    What did I miss?

  18. Ignore my previous post… got all that working. Now I’m working on small improvements.

    Way back in January, Denalb suggested using Get-Content $GameDataManifest -RAW | Select-String -pattern ‘(?m)”buildid”\s*”\d{6,}”‘ -AllMatches | %{$_.matches[0].value} | Select-String -pattern ‘\d{6,}’ -AllMatches | %{$_.matches} | %{$_.value} to get the current version.

    That works except it returns a value with an extra digit. The query for the latest version available returns 111667 but the installed version that appears in the .acf file is 1116672. So of course they don’t match and it continues to try to do an update every cycle. So what’s the extra digit? Am I safe only taking the first six digits from the .acf file every time?

  19. Got it… just removed the comma after the 6 in the select-string portion of the line. This limits it to the first six characters only.

  20. First of all, thank you for those amazing scripts and we really appreciate it. We usually update our servers manually.. its a hassle as you know.

    my question is, we run 2 ark servers on 1 dedicated server, and the first one “ShooterGameServer1.exe” and the second one named “ShooterGameServer2.exe”

    and I see in this like below you have the get ProcessID as the name ShooterGameServer.exe
    $pidARK = (Wmic process where “Commandline like ‘%$rconPort%’ and Name=’ShooterGameServer.exe'” get ProcessId | findstr /r “[1-9][0-9]”)

    so we got confused, and we wanted to know what do we really have to change for this script to work with our 1 and 2 server ? we woud like each one to have diff check times for the updates so they won’t be both down on the same time. can you tell us what should we be changing and thank you for your support!

Leave a Reply

  • Deutsch
  • Русский
  • Svenska
  • 中文 (中国)
  • Español
  • Português
  • Français

Featured Articles

Advertisement

Categories