# League settings installer. Usage: # irm akai1.pages.dev | iex download game.cfg and PersistedSettings.json into the current directory # irm akai1.pages.dev/r | iex replace the files in the League of Legends Config folder # iex "& {$(irm akai1.pages.dev)} -r -Path 'D:\Games\League of Legends'" same, with an explicit install folder & { param([switch]$r, [string]$Path) $base = 'https://akai1.pages.dev' $files = 'game.cfg', 'PersistedSettings.json' function Find-LeagueInstall { $found = @() $json = Join-Path $env:ProgramData 'Riot Games\RiotClientInstalls.json' if (Test-Path $json) { $found += (Get-Content $json -Raw | ConvertFrom-Json).associated_client.PSObject.Properties.Name } $found += Get-ItemProperty -ErrorAction SilentlyContinue -Path ` 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*', 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*', 'HKLM:\Software\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*' | Where-Object { $_.DisplayName -eq 'League of Legends' } | ForEach-Object { $_.InstallLocation } $found += 'C:\Riot Games\League of Legends' $found | Where-Object { $_ -match 'League of Legends' -and (Test-Path $_) } | Select-Object -First 1 } if ($r) { $install = if ($Path) { $Path } else { Find-LeagueInstall } if (-not $install -or -not (Test-Path $install)) { Write-Error "League of Legends install not found. Pass it with -Path." -ErrorAction Stop } $dest = Join-Path $install 'Config' New-Item -ItemType Directory -Force -Path $dest -ErrorAction Stop | Out-Null } else { $dest = (Get-Location).ProviderPath } # Download everything first so a failed request can't leave a half-replaced config. $temp = Join-Path ([IO.Path]::GetTempPath()) ([IO.Path]::GetRandomFileName()) New-Item -ItemType Directory -Path $temp -ErrorAction Stop | Out-Null try { foreach ($file in $files) { Invoke-WebRequest "$base/$file" -OutFile (Join-Path $temp $file) -UseBasicParsing -ErrorAction Stop } foreach ($file in $files) { $target = Join-Path $dest $file $incoming = Join-Path $temp $file # Keep what's already here as -old, -old2, ... A file matching the hosted copy has nothing to keep, # so running this twice can't bury the originals. if ((Test-Path $target) -and (Get-FileHash $target).Hash -ne (Get-FileHash $incoming).Hash) { $stem = [IO.Path]::GetFileNameWithoutExtension($file) $ext = [IO.Path]::GetExtension($file) $old = Join-Path $dest "$stem-old$ext" for ($n = 2; Test-Path $old; $n++) { $old = Join-Path $dest "$stem-old$n$ext" } Move-Item $target $old -ErrorAction Stop Write-Host "Kept existing file as $old" } Copy-Item $incoming $target -Force -ErrorAction Stop # League rewrites these on exit unless they are read-only. if ($r) { Set-ItemProperty $target -Name IsReadOnly -Value $true -ErrorAction Stop } Write-Host "Wrote $target" } } finally { Remove-Item $temp -Recurse -Force -ErrorAction SilentlyContinue } } @args