Created
February 24, 2022 02:17
-
-
Save adntaha/ac4325ef7f546adcbd460d7e7b88d7bd to your computer and use it in GitHub Desktop.
OpenAsar (https://github.com/GooseMod/OpenAsar) installer that works on Discord's different release branches, made with PowerShell for Windows
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$openasar_uri = "https://github.com/GooseMod/OpenAsar/releases/download/nightly/app.asar" | |
$discord = (Read-Host "Discord release (stable|ptb|canary|development): ").ToLower() -replace " ","" | |
$discord_name = "Discord" + (Get-Culture).TextInfo.ToTitleCase($discord) | |
function Stop-Discord { | |
$processes = Get-Process -Name $discord_name | |
if ($processes.Count -gt 0) { | |
$processes | Stop-Process | |
} | |
} | |
function Start-Discord { | |
Start-Process | |
-FilePath "$Env:LocalAppData\$discord_name\Update.exe" | |
-ArgumentList "--processStart $discord_name.exe" | |
-Verb runAs | |
-ErrorAction SilentlyContinue | |
} | |
function Move-Backup { | |
param ([string] $file) | |
$backup = $file + ".backup" | |
Move-Item -Path $file -Destination $backup -Force | |
} | |
function Find-AppDotAsar { | |
if ($discord -eq "stable") { | |
$discord_path = "$Env:LocalAppData\Discord" | |
} elseif ($discord -match "(ptb|canary|development)") { | |
$discord_path = "$Env:LocalAppData\$discord_name" | |
} else { | |
Write-Host "Invalid Discord release type." -ForegroundColor Red | |
exit 1 | |
} | |
foreach ($dir in (Get-ChildItem -Path $discord_path -Recurse)) { | |
if ($dir.Name -like "app-*") { | |
$app_dir = $dir.FullName | |
break | |
} | |
} | |
$app_dot_asar = "$app_dir\app.asar" | |
return $app_dot_asar | |
} | |
Stop-Discord | |
$app_dot_asar = Find-AppDotAsar | |
Move-Backup -file $app_dot_asar | |
Invoke-WebRequest -Uri $openasar_uri -OutFile $app_dot_asar | |
Write-Host "Done." -ForegroundColor Green | |
Start-Discord |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment