PortValhalla/scripts/Windows/Software/TrackMania Nations Forever/Install.ps1

32 lines
1.3 KiB
PowerShell
Raw Normal View History

2023-07-12 20:37:31 +00:00
#!/bin/pwsh
2024-08-07 19:05:32 +00:00
. "$PSScriptRoot/../../../Common/Scripts/Context.ps1";
2023-06-08 00:28:33 +00:00
$null = New-Module {
$path = "$HOME/Documents/TmForever";
$softwareName = "TmNationsForever";
2023-06-30 10:19:54 +00:00
function Backup-TmNations([Context] $context) {
Write-Host "Backing up TrackMania Nations Forever";
2023-06-08 00:28:33 +00:00
$context.Backup($path, $context.SoftwareArchive($softwareName), @("-i@`"$PSScriptRoot/include.txt`""));
}
function Restore-TmNations([Context] $context) {
$features = @("DirectPlay", "NetFx3");
Write-Host "Restoring TrackMania Nations Forever";
2023-07-02 11:53:19 +00:00
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;
}
}
2023-07-02 11:53:19 +00:00
Write-Information "Installing TrackMania Nations Forever";
winget install --accept-source-agreements --accept-package-agreements -e --id Nadeo.TrackManiaNationsForever;
2023-07-02 11:53:19 +00:00
Write-Information "Removing Desktop Icon";
2023-07-16 12:52:53 +00:00
$context.RemoveDesktopIcon("*TmNationsForever*");
2023-07-02 11:53:19 +00:00
Write-Information "Restoring Files";
$context.Restore($context.SoftwareArchive($softwareName), $path);
}
}