Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <#
- 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
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement