PortValhalla/scripts/Windows/Software/reWASD/Manage.ps1

32 lines
1.1 KiB
PowerShell

#!/bin/pwsh
$null = New-Module {
. "$PSScriptRoot/../../../Common/Scripts/BrowserAutomation.ps1";
. "$PSScriptRoot/../../../Common/Scripts/Context.ps1";
$path = "$env:PUBLIC/Documents/reWASD";
$softwareName = "reWASD";
function Backup-reWASD([Context] $context) {
Write-Host "Backing up reWASD";
$context.Backup($path, $context.SoftwareArchive($softwareName), @("-x@`"$PSScriptRoot/exclude.txt`""));
}
function Restore-reWASD([Context] $context) {
Write-Host "Restoring reWASD";
$tempDir = $context.GetTempDirectory();
Write-Information "Downloading reWASD";
$file = Start-BrowserDownload $context "https://rewasd.com/" 'a.btn-default[href="#"]' $tempDir;
Write-Information "Installing reWASD";
Start-Process -Wait -FilePath $file.FullName -ArgumentList "/S";
Write-Information "Restoring files";
$context.Restore($context.SoftwareArchive($softwareName), $path, @("-aos"));
Write-Information "Removing desktop icon";
$context.RemoveDesktopIcon("*reWASD*");
Remove-Item -Recurse $tempDir;
}
}