PortValhalla/scripts/Windows/Software/TrackMania United Forever/Manage.ps1

41 lines
1.6 KiB
PowerShell
Raw Normal View History

2023-07-12 20:37:31 +00:00
#!/bin/pwsh
. "$PSScriptRoot/../../Scripts/Context.ps1";
2023-06-06 23:21:47 +00:00
2023-06-08 00:28:33 +00:00
$null = New-Module {
$path = "$HOME/Documents/TrackMania";
$softwareName = "TmUnitedForever";
2023-06-30 10:19:54 +00:00
function Backup-TmUnited([Context] $context) {
Write-Host "Backing up TrackMania United Forever";
2023-06-08 00:28:33 +00:00
$context.Backup($path, $context.SoftwareArchive($softwareName), @("-i@`"$PSScriptRoot/include.txt`""));
}
function Restore-TmUnited([Context] $context) {
$setupFile = "TmUnitedForever.exe";
$features = @("DirectPlay", "NetFx3");
Write-Host "Restoring TrackMania United Forever";
foreach ($feature in $features) {
2023-07-02 17:00:25 +00:00
if ((Get-WindowsOptionalFeature -Online -FeatureName $feature).State -ne "Enabled") {
Write-Information "Enabling the ``$feature`` feature";
2023-07-19 21:19:05 +00:00
$null = Enable-WindowsOptionalFeature -Online -All -FeatureName $feature;
}
}
$tempDir = $context.GetTempDirectory();
Push-Location $tempDir;
Write-Information "Downloading TrackMania United Forever setup";
Invoke-WebRequest "http://files.trackmaniaforever.com/tmunitedforever_setup.exe" -OutFile "$setupFile";
Write-Information "Installing TrackMania United Forever";
Start-Process -Wait -FilePath $setupFile -ArgumentList @("/Silent");
Write-Information "Removing desktop icon";
$context.RemoveDesktopIcon("*TmUnitedForever*");
Write-Information "Restoring files";
$context.Restore($context.SoftwareArchive($softwareName), $path);
Pop-Location;
Remove-Item -Recurse $tempDir;
}
2023-06-06 23:21:47 +00:00
}