Add a function for removing desktop icons

This commit is contained in:
Manuel Thalmann 2023-07-16 12:32:46 +02:00
parent 18b962aa1e
commit 80efc58ee7
4 changed files with 7 additions and 3 deletions

View file

@ -24,6 +24,10 @@ class Context {
}
}
[void] RemoveDesktopIcon($pattern) {
Remove-Item "$env:PUBLIC/Desktop/$pattern";
}
[Microsoft.Win32.RegistryKey] EnsureConfigKey() {
if (-not (Test-Path $this.ConfigRoot)) {
$null = New-Item $this.ConfigRoot;

View file

@ -24,7 +24,7 @@ $null = New-Module {
Write-Information "Installing TrackMania Nations Forever";
winget install --accept-source-agreements --accept-package-agreements -e --id Nadeo.TrackManiaNationsForever;
Write-Information "Removing Desktop Icon";
Remove-Item "$env:PUBLIC\Desktop\*TmNationsForever*";
$context.RemoveDesktopIcon("*TmNationsForever");
Write-Information "Restoring Files";
$context.Restore($context.SoftwareArchive($softwareName), $path);
}

View file

@ -30,7 +30,7 @@ $null = New-Module {
Write-Information "Installing TrackMania United Forever";
Start-Process -Wait -FilePath $setupFile -ArgumentList @("/Silent");
Write-Information "Removing desktop icon";
Remove-Item "$env:PUBLIC\Desktop\*TmUnitedForever*";
$context.RemoveDesktopIcon("*TmUnitedForever*");
Write-Information "Restoring files";
$context.Restore($context.SoftwareArchive($softwareName), $path);
Pop-Location;

View file

@ -19,7 +19,7 @@ $null = New-Module {
Write-Host "Restoring osu!";
Write-Information "Installing osu!";
choco install -y osu;
Remove-Item "$env:PUBLIC\Desktop\*osu*";
$context.RemoveDesktopIcon("*osu*");
Write-Information "Restoring files";
$context.Restore($context.SoftwareArchive($softwareName), $path);
$configName = "osu!.$env:USERNAME.cfg";