Automatic Core Updater (windows)

I wanted to share my powershell script that automatically fetches the list of cores and downloads the ones that are updated in the server, it assumes you have installed Retroarch to it’s default location, but if you didn’t change $cores_path and $logfile to their appropriate location.

  • Run it by right click it and select “Run with powershell”.

  • If you are asked for confirmation for security reasons type: yes

NOTE: the first time it runs it will re-download all your cores, it’s normal. (only the first time)

If you want to make it a scheduled task the security warning may be annoying, you can bypass it by making a batch script with this code:

powershell -noprofile -nologo -executionpolicy bypass -File RA_cores_updater.ps1

No more to say, here is the Link to the Retroarch Automatic Core Updater for windows (Right click it and “save as”)

5 Likes

Thanks for this. When I initially ran it, the script wasn’t able to connect to the buildbot website to download the timestamps. I had to replace: Start-BitsTransfer -Source $cores_url/.index-extended -Destination $cores_path\.timestamps.new -TransferType Download

With this:

Invoke-RestMethod -uri $cores_url/.index-extended -OutFile $cores_path\.timestamps.new

Which is a little odd since Start-BitsTransfer works fine when actually downloading the zips. But this was very helpful, thanks!

1 Like

Just wanted to add a quick note to this.

First, thanks for the script! This is very helpful.

If your copy of Retroarch is installed anywhere but the default location, this doesn’t work. You’ll need to edit lines 11 and 12 to set the proper paths for the cores and output files.

$cores_path="c:\path\to\retroarch\cores"
$logfile="$cores_path\cores_updater.log"

Other than that, :metal: !

2 Likes

Works great! Just what I was looking for…

@Nadonate, do you know Stellar?

For sure! I use it to keep RA up to date. For updating cores, I was looking for something more automated.

First of all thanks for this great script! However when I run it it tends to generate errors, see below. Any thoughts? It seems to be running ok for most of them. It’s occurring on this line:

$current_timestamp=$timestamp_new.ToString($timestamp_new).Split(" ")[0]

  • 2020-02-11 UPDATED mame2003_plus_libretro.dll
  • 2019-12-02 UPDATED mame2010_libretro.dll
  • 2020-03-18 UPDATED mame2015_libretro.dll
  • 2020-02-09 UPDATED mame2016_libretro.dll
You cannot call a method on a null-valued expression.
At line:26 char:13
+             $current_timestamp=$timestamp_new.ToString($timestamp_new ...
+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull
  • 2020-02-09 UPDATED mame_libretro.dll
  • 2019-12-02 UPDATED mednafen_gba_libretro.dll
  • 2020-03-26 UPDATED thepowdertoy_libretro.dll
  • 2020-05-09 UPDATED tic80_libretro.dll
  • 2020-04-19 UPDATED tyrquake_libretro.dll
Cannot find an overload for "ToString" and the argument count: "1".
At line:26 char:13
+             $current_timestamp=$timestamp_new.ToString($timestamp_new ...
+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodException
    + FullyQualifiedErrorId : MethodCountCouldNotFindBest
  • 2020-04-19 UPDATED ume2015_libretro.dll
  • 2020-03-12 UPDATED vbam_libretro.dll
  • 2020-01-08 UPDATED vba_next_libretro.dll

Retroarch added a core updater for installed cores a while ago, i would suggest everyone to use that instead of my old script. I also suggest to make a backup before updating, some core updates may break compatibility with savestates or introduce problems, so be careful if you are trying to finish a game, it could ruin your day.

@alfrix Thank you for this script. Even though RetroArch now has a built-in core updater I still find this script useful for automating the core updates.

I also wanted to share some tweaks I made that fix the error messages that are often produced as noted by @rodww.

Those errors will go away if you replace lines 34-36 with the following:

        $timestamp_old=$(Get-Content "$cores_path\.timestamps.old" | Select-String -pattern "(?<=\s)$corename")
        $timestamp_new=$(Get-Content "$cores_path\.timestamps.new"| Select-String -pattern "(?<=\s)$corename")
        if ( $timestamp_new -ne $null )
        {
            $current_timestamp=$timestamp_new.ToString($timestamp_new).Split(" ")[0]
        }

The error “You cannot call a method on a null-valued expression” will happen if you have cores that have been renamed or discontinued. An example of this is that “4do_libretro” has been renamed to “opera_libretro”. In such a case there will be no entry for it in the file “.timestamps.new” so the value for “$timestamp_new” will be null and you will get that error. By adding the if statement that only sets the value for “$current_timestamp” if the value of “$timestamp_new” is not null, you will avoid those errors. What would be great is if there is a way to determine if a core you have has indeed had a name change and then remove the old one and download the newly named one but that seems like quite a bit of work.

The error "Cannot find an overload for “ToString” and the argument count: “1"” is caused when The operation that sets the value for “$timestamp_old” or “$timestamp_new” finds more than one match for the core name in “.timestamps.old” or “.timestamps.old” files. An example of this is that when checking the timestamp for “mame_libretro” currently the value of “$timestamp_new” will be set to:

2020-04-05 8e456fab hbmame_libretro.dll.zip
2020-07-29 e550ad3e mame_libretro.dll.zip

This is because the string “mame_libretro.dll” is also contained in “hbmame_libretro.dll” so there are two matches. This can be fixed by doing a regex match instead of a simple match when parsing “.timestamps.old” and “.timestamps.old” and setting the values of “$timestamp_old” and “$timestamp_new”. I used “(?<=\s)$corename” as the pattern to match which basically matches the value of “$corename” only when it is preceded by a space. Because of the format of “.timestamps.old” and “.timestamps.old” this will make sure that the core names are only matched where intended and not when they also happen to be a part of any other string in those files.

I hope this is helpful.

I think the default when I installed RA recently was in C:\RetroArch-Win64\cores, but the script expects it to be in $env:appdata\retroarch\cores where RA is not in the Roaming AppData.

I’m also getting this when trying to run in Windows PowerShell ISE, but it’s working fine on the Windows PowerShell command-line:

Start-BitsTransfer : Object reference not set to an instance of an object. At C:\Users\johnr\Downloads\RA_cores_updater.ps1:19 char:1

  • Start-BitsTransfer -Source $cores_url/.index-extended -Destination $c …
  •   + CategoryInfo          : NotSpecified: (:) [Start-BitsTransfer], NullReferenceException
      + FullyQualifiedErrorId : System.NullReferenceException,Microsoft.BackgroundIntelligentTransfer.Management.NewBitsTrans 
     ferCommand
    
    

FAILED to download timestamps