PortValhalla/scripts/Windows/Software/osu!lazer/Manage.ps1

39 lines
1.3 KiB
PowerShell
Raw Normal View History

2023-07-12 20:37:31 +00:00
#!/bin/pwsh
2023-06-07 18:24:43 +00:00
. "$PSScriptRoot/../../Scripts/Context.ps1";
2023-06-08 00:28:33 +00:00
$null = New-Module {
$path = "$env:APPDATA/osu";
$softwareName = "osu!lazer";
2023-06-30 10:19:54 +00:00
function Backup-OsuLazer([Context] $context) {
Write-Host "Backing up osu!lazer";
2023-06-08 00:28:33 +00:00
$context.Backup($path, $context.SoftwareArchive($softwareName), @("-i@`"$PSScriptRoot/include.txt`"", "-i!*.realm", "-i!*.db"));
}
2023-07-02 13:12:56 +00:00
function Restore-OsuLazer([Context] $context) {
Write-Host "Restoring osu!lazer";
Write-Information "Restoring files";
$context.Restore($context.SoftwareArchive($softwareName), $path);
Write-Information "Installing osu!lazer";
$installerName = "osu!lazer.exe";
2023-07-12 16:23:59 +00:00
$processName = "osu!";
2023-07-02 13:12:56 +00:00
$tempDir = $context.GetTempDirectory();
Push-Location $tempDir;
Invoke-WebRequest "https://github.com/ppy/osu/releases/latest/download/install.exe" -OutFile $installerName;
2023-07-12 16:23:59 +00:00
$process = Start-Process -FilePath $installerName;
while (-not (Get-Process -ErrorAction "SilentlyContinue" $processName)) {
Start-Sleep 1;
}
Start-Sleep 10;
Get-Process $processName | Stop-Process -Force;
Wait-Process $process;
2023-07-02 21:31:56 +00:00
Remove-Item "~\Desktop\*osu*";
2023-07-02 13:12:56 +00:00
Pop-Location;
Remove-Item -Recurse $tempDir;
}
2023-07-12 20:44:20 +00:00
}