Jump to content
LaunchBox Community Forums

Updating RetroArch


mikeisfly

Recommended Posts

I wanted to update my RetroArch installation and found a cool video on YouTube that explains the process here:
Updating RetroArch
Based on this video I created a PowerShell script for anyone looking to automate this process:
Please feel free to look at it and try it. I have only tested it on two of my machines but should help to take some of the pain out of the upgrade process. If this is helpful and enough people test it maybe the admins can make this a sticky.
Don't judge me on my code, I made this fairly quick and have not cleaned it up much.
Thanks for RetroArch and hope this helps. Look forward to your feedback.
 
Directions:
1. Copy text from pastebin and put it in a text file and save the file with a .ps1 extension.
2. Copy powershell script to a folder close to where your retroarch folder is located (I use the parent folder to retroarch)
3. Open PowerShell command prompt and navigate to where the folder is located
4. Execute the powershell script (Example: ps c:\arcade> .\retroarchupdate.ps1)
 
The Script takes two arguments "RetroArch Path" "Updated RetroArch zip file"
Example : .\retroarchupdate.ps1 c:\arcade\retroarch retroarch.7z
 
These arguments can be hard-coded into the script in the param block to make life easier, just put them between the single quotes.
 
Here is the code for your review: I will also attach the file as well.
 
<# 

Arthor : Michael Gates
Date : 6 September 2017

This script will automate the upgrading of RetroArch. It Requires Winrar to be installed in your c:\program files folder and the name of the upgraded file to be named retroarch.7z

Syntax .\"RetroArch Upgrade v2.ps1" c:\arcade\retroarch retroarch.7z

If no arguments are given then the default values in the Parameter block will be used. You can change these to fit your needs

This script is free to use and I take no responsibility for any damage this may cause to your system or your RetroARch installation. Remember to alway make a back up before using this.

Credit goes to:

https://adamstech.wordpress.com/2011/05/12/how-to-properly-pause-a-powershell-script/ (I borrowed the pause function)
https://stackoverflow.com/questions/11412617/get-a-folder-path-from-the-explorer-menu-to-a-powershell-variable (Helped me use explorer instead of commandline)
http://www.powershellmagazine.com/2013/06/28/pstip-using-the-system-windows-forms-folderbrowserdialog-class/ (Helped with picking selected path)
http://www.powershellmagazine.com/2013/07/01/pstip-using-the-system-windows-forms-openfiledialog-class/ (Helped with filtering file input)
https://stackoverflow.com/questions/32014711/how-do-you-call-windows-explorer-with-a-file-selected-from-powershell (Helped with selecting the file in file explorer)
#>


Param #Change value here to set the default value if not specified at command line
	(
		[String]$RetroArchPath = '',
		[String]$RetroArchUpgradeFile = '' 
		
				
	)
	
Function Get-Path
		{
			$Path = pwd
			$Path = $Path.path
			Return $Path
		}

Function SelectFolder ($RootFolder, $Description)
    {
        Add-Type -AssemblyName System.Windows.Forms
        $FolderBrowser = New-Object System.Windows.Forms.FolderBrowserDialog -Property @{SelectedPath = $RootFolder}

        $FolderBrowser.Description = $Description
        
        [void]$FolderBrowser.ShowDialog()
        Return $FolderBrowser.SelectedPath
    }
	
Function SelectFile ($RootFolder, $Description)
    {
        Add-Type -AssemblyName System.Windows.Forms
        $File = New-Object System.Windows.Forms.OpenFileDialog -Property @{Filter = 'RetroArch Upgrade File (*.7z)|*.7z|All Files (*.*)|*.*'}
        $File.InitialDirectory = $RootFolder
        $File.Title = $Description
        [void]$File.ShowDialog()
        Return $File.FileName
    }

Function Pause ($Message1, $Message2) 

    {
       # If ($psISE)
        #{
            # The "ReadKey" functionality is not supported in Windows PowerShell ISE.
            $Shell = New-Object -ComObject "WScript.Shell"
            $Button = $Shell.Popup($Message1, 0, $Message2, 0)
            Return
        #}
    }

#Function Pause ($message)
#	{
#		Write-Host $Message
#		$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
#	}
	
Function Check-Path ($PathString)
	{
		$x = ( !( $PathString[-1] -eq "\" ) )
		IF ( $x ) { $PathString = $PathString + "\" }
		Return $PathString
	}
				
Function Main()
	{
		
		$Assets = "assets", "autoconfig", "config", "filters", "overlays", "saves", "shaders", "states", "system", "cores", "retroarch.cfg", "retroarch.default.cfg", "retroarch-core-options.cfg"
		$RootFolder = Get-Path

		If ($RetroArchPath -eq "")
			{
				
				$RetroArchPath = SelectFolder $RootFolder "Where is your RetroArch Installed?"
				                			
            }

		If ($RetroArchUpgradeFile -eq "")
			{
				$RetroArchUpgradeFile = SelectFile $RootFolder "Select the File that contains your RetroArch Upgrade."
			}
	
		$RetroArchPath = Check-Path $RetroArchPath
		
		If (!(Test-Path TmpUpgrade))
			{
				New-Item -ItemType Directory TmpUpgrade | Out-Null
			}
		ForEach ($Item in $Assets)
			{
				$TestCase = $RetroArchPath + $Item
				If (Test-Path $TestCase)
					{
						Copy-Item $TestCase TmpUpgrade -Force 
					}
			}
			
		$WinRAR = '"c:\program files\winrar\winrar.exe"' 
		$WinRARTmpDir = '\RetoArchNewTmp'
		 
		
		& WinRAR x -y -r $RetroArchUpgradeFile  *.* $RetroArchPath | Out-Null
		
		ForEach ($Item in $Assets)
			{
				If (Test-Path TmpUpgrade\$Item) 
					{
						Copy-Item TmpUpgrade\$Item $RetroArchPath -Force
						Remove-Item TmpUpgrade\$Item -Force -Recurse
						
					}
			}
		
		Remove-Item TmpUpgrade
		Pause "Press OK to terminate" "Completed!"
		
	}
	
Main

 

 
  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...