# 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 } $stamp = Get-Date -Format 'yyyyMMdd-HHmmss' foreach ($file in $files) { $target = Join-Path $dest $file if ($r -and (Test-Path $target)) { Copy-Item $target "$target.$stamp.bak" -Force -ErrorAction Stop } Copy-Item (Join-Path $temp $file) $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