2023-07-12 20:37:31 +00:00
|
|
|
#!/bin/pwsh
|
2023-06-07 17:15:47 +00:00
|
|
|
. "$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) {
|
2023-06-30 12:23:20 +00:00
|
|
|
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`""));
|
|
|
|
}
|
2023-07-02 11:58:23 +00:00
|
|
|
|
|
|
|
function Restore-TmUnited([Context] $context) {
|
2023-07-12 16:11:55 +00:00
|
|
|
$setupFile = "TmUnitedForever.exe";
|
2023-07-02 16:05:06 +00:00
|
|
|
$features = @("DirectPlay", "NetFx3");
|
2023-07-02 11:58:23 +00:00
|
|
|
Write-Host "Restoring TrackMania United Forever";
|
|
|
|
|
2023-07-02 16:05:06 +00:00
|
|
|
foreach ($feature in $features) {
|
2023-07-02 17:00:25 +00:00
|
|
|
if ((Get-WindowsOptionalFeature -Online -FeatureName $feature).State -ne "Enabled") {
|
2023-07-02 16:05:06 +00:00
|
|
|
Write-Information "Enabling the ``$feature`` feature";
|
2023-07-19 21:19:05 +00:00
|
|
|
$null = Enable-WindowsOptionalFeature -Online -All -FeatureName $feature;
|
2023-07-02 16:05:06 +00:00
|
|
|
}
|
2023-07-02 11:58:23 +00:00
|
|
|
}
|
|
|
|
|
2023-07-12 16:11:55 +00:00
|
|
|
$tempDir = $context.GetTempDirectory();
|
|
|
|
Push-Location $tempDir;
|
|
|
|
Write-Information "Downloading TrackMania United Forever setup";
|
|
|
|
Invoke-WebRequest "http://files.trackmaniaforever.com/tmunitedforever_setup.exe" -OutFile "$setupFile";
|
2023-07-02 11:58:23 +00:00
|
|
|
|
|
|
|
Write-Information "Installing TrackMania United Forever";
|
2023-07-12 16:11:55 +00:00
|
|
|
Start-Process -Wait -FilePath $setupFile -ArgumentList @("/Silent");
|
2023-07-02 11:58:23 +00:00
|
|
|
Write-Information "Removing desktop icon";
|
2023-07-16 10:32:46 +00:00
|
|
|
$context.RemoveDesktopIcon("*TmUnitedForever*");
|
2023-07-02 11:58:23 +00:00
|
|
|
Write-Information "Restoring files";
|
|
|
|
$context.Restore($context.SoftwareArchive($softwareName), $path);
|
2023-07-12 16:11:55 +00:00
|
|
|
Pop-Location;
|
|
|
|
|
|
|
|
Remove-Item -Recurse $tempDir;
|
2023-07-02 11:58:23 +00:00
|
|
|
}
|
2023-06-06 23:21:47 +00:00
|
|
|
}
|