Advertisement
Androxilogin

Update PCSX2 to the latest dev build from Powershell

Feb 12th, 2022
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.90 KB | None | 0 0
  1. #Define PCSX2 path, repo url and version needed
  2. $runFolder = Split-Path $MyInvocation.MyCommand.Path -Parent
  3. $githubUrl = 'https://api.github.com/repos/PCSX2/pcsx2/releases'
  4. $releaseType = '*' + '64bit-AVX2.7z'
  5.  
  6. function DownloadAndExtractNewVersion {
  7. param ([string]$DownloadUrl, [string]$Version)
  8.  
  9. #Define paths
  10. $tempDirectory = $runFolder + '\latest'
  11. $archivePath = $tempDirectory + '\pcsx2.7z'
  12. $latestBuildDirectory = $tempDirectory + '\pcsx2latest'
  13. $latestVersionFilePath = $latestBuildDirectory + '\version.ini'
  14.  
  15. #Create temp folder for new version
  16. New-Item -Path $tempDirectory -ItemType 'directory'
  17.  
  18. #Download and extract PCSX2
  19. Invoke-WebRequest $DownloadUrl -OutFile $archivePath
  20. Expand-7Zip -ArchiveFileName $archivePath -TargetPath $latestBuildDirectory
  21.  
  22. #Write version to file
  23. Set-Content -Path $latestVersionFilePath -Value $Version
  24.  
  25. #Copy/Overwrite what is in the emulator folder
  26. Copy-Item -Path ($latestBuildDirectory + '\*') -Destination $runFolder -Force -Recurse -PassThru
  27.  
  28. #Delete downloaded PCSX2 files when done to prep for next version
  29. Remove-Item -Path $tempDirectory -recurse
  30. }
  31.  
  32. #Entry point
  33. $releases = Invoke-WebRequest $githubUrl | ConvertFrom-Json
  34.  
  35. #Get latest version name
  36. $newVersion = $releases[0].tag_name
  37.  
  38. #Get download url
  39. $downloadUrl = ($releases[0].assets | Where-Object { $_.name -like $releaseType }).browser_download_url
  40.  
  41. #Get current version present, if any
  42. if (Test-Path ($runFolder + '\version.ini')) {
  43. $currentVersion = Get-Content -Path ($runFolder + '\version.ini')
  44. }
  45.  
  46. #Compare version names; if our version is not the most recent one, then download it
  47. if ($currentVersion -ne $newVersion) {
  48. DownloadAndExtractNewVersion -DownloadUrl $downloadUrl -Version $newVersion
  49. Write-Host 'PCSX2 updated'
  50. }
  51. else {
  52. Write-Host 'PCSX2 already up to date'
  53. }
  54.  
  55. Read-Host
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement