Automatically download TrackMania United setup

This commit is contained in:
Manuel Thalmann 2023-07-12 18:11:55 +02:00
parent 48a9234081
commit e64de7147a

View file

@ -10,6 +10,7 @@ $null = New-Module {
}
function Restore-TmUnited([Context] $context) {
$setupFile = "TmUnitedForever.exe";
$features = @("DirectPlay", "NetFx3");
Write-Host "Restoring TrackMania United Forever";
@ -20,23 +21,19 @@ $null = New-Module {
}
}
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.";
}
}
$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 $exePath -ArgumentList @("/Silent");
Start-Process -Wait -FilePath $setupFile -ArgumentList @("/Silent");
Write-Information "Removing desktop icon";
Remove-Item "$env:PUBLIC\Desktop\*TmUnitedForever*";
Write-Information "Restoring files";
$context.Restore($context.SoftwareArchive($softwareName), $path);
Remove-Item $exePath;
Pop-Location;
Remove-Item -Recurse $tempDir;
}
}