#shortcut example #C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -NoLogo -File "P:\Program Files (x86)\PCSX2\PCSX2 AutoUpdater.ps1" ######################################### #user vars $runwiz = $false $forceupdate = $false $dest = $PSScriptRoot ######################################### ######################################### #Author: Mason #Version: 0.9.7 ######################################### #vars $baseurl = "http://buildbot.orphis.net/pcsx2/" $zfile = $env:TEMP + "\pcsx2.7z" $zfolder = $env:TEMP + "\pcsx2" $verini = "$dest\version.ini" $portini = "$dest\portable.ini" # clear host Clear-Host # get baseurl $reqs = Invoke-WebRequest -Uri $baseurl # find all pcsx2 builds $newver = $($reqs.Links | where{$_.innerText -match "^v.[.]"} | measure -Property innerText -Maximum).Maximum $newobj = $reqs.Links | where{$_.innerText -eq "Download"} #compare versions ##read current version $oldver = Get-Content -Path $verini -ErrorAction SilentlyContinue ##compare verisons if (($oldver -eq $newver) -and ($forceupdate -eq $false)) { Write-Host "allready up to date" Start-Process -FilePath "$dest\PCSX2.exe" Exit }else{ Write-Host "installed version: $oldver" Write-Host "updating to build: $newver" Remove-Item -Path $verini -ErrorAction SilentlyContinue Add-Content -Value $newver -Path $verini } # combine to download url $ourl = "http://buildbot.orphis.net" + $newobj[0].href $url = $ourl.Replace("amp;","") # clearup temp if(Test-Path -Path $zfile){Remove-Item -Path $zfile -Force} if(Test-Path -Path $zfolder){Remove-iTem -Path $zfolder -Force -Recurse} $null = New-Item -Path $zfolder -ItemType Directory # download file Invoke-WebRequest -uri $url -Method GET -Header @{Referer = $baseurl} -OutFile $zfile #loading modules Import-Module PSCX -ErrorAction Stop #required for expand-archive # extract files Expand-Archive -Path $zfile -OutputPath $zfolder # create destination path $isfolder = $(Get-ChildItem -Path $zfolder).Name $source = $zfolder + "\$isfolder" # get source files $files = Get-ChildItem -Path $source #copy files foreach ($file in $files){ Copy-Item -Path $file.FullName -Destination $dest -recurse -Force } # set WinWizard if ($runwiz -eq $false){ Add-Content -Value "RunWizard=0" -Path $portini } Start-Process -FilePath "$dest\PCSX2.exe"