. "$PSScriptRoot/../../Scripts/Context.ps1"; $null = New-Module { $path = "$HOME/Documents/TrackMania"; $softwareName = "TmUnitedForever"; function Backup-TmUnited([Context] $context) { Write-Host "Backing up TrackMania United Forever"; $context.Backup($path, $context.SoftwareArchive($softwareName), @("-i@`"$PSScriptRoot/include.txt`"")); } function Restore-TmUnited([Context] $context) { $features = @("DirectPlay", "NetFx3"); Write-Host "Restoring TrackMania United Forever"; foreach ($feature in $features) { if (-not (Get-WindowsOptionalFeature -Online -FeatureName $feature).State) { Write-Information "Enabling the ``$feature`` feature"; Enable-WindowsOptionalFeature -Online -All -FeatureName $feature; } } Write-Information "Determining location of setup file"; $exePath = ""; while (-not (Test-Path $exePath)) { $exePath = Read-Host "Please drag'n'drop the setup file here or type the absolute path to the file"; if (-not (Test-Path $exePath)) { Write-Error "A file at the specified path could not be found."; } } Write-Information "Installing TrackMania United Forever"; Start-Process -Wait -FilePath $exePath -ArgumentList @("/Silent"); Write-Information "Removing desktop icon"; Remove-Item "$env:PUBLIC\Desktop\*TmUnitedForever*"; Write-Information "Restoring files"; $context.Restore($context.SoftwareArchive($softwareName), $path); } }