From 32030e145561838fa70544476f55ecdecce3325c Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Sun, 16 Jul 2023 12:32:46 +0200 Subject: [PATCH] Add a function for removing desktop icons --- scripts/Windows/Scripts/Context.ps1 | 4 ++++ .../Windows/Software/TrackMania Nations Forever/Manage.ps1 | 2 +- scripts/Windows/Software/TrackMania United Forever/Manage.ps1 | 2 +- scripts/Windows/Software/osu!/Manage.ps1 | 2 +- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/scripts/Windows/Scripts/Context.ps1 b/scripts/Windows/Scripts/Context.ps1 index 67e2871c..9700bae0 100644 --- a/scripts/Windows/Scripts/Context.ps1 +++ b/scripts/Windows/Scripts/Context.ps1 @@ -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; diff --git a/scripts/Windows/Software/TrackMania Nations Forever/Manage.ps1 b/scripts/Windows/Software/TrackMania Nations Forever/Manage.ps1 index 7f4e3758..07572421 100644 --- a/scripts/Windows/Software/TrackMania Nations Forever/Manage.ps1 +++ b/scripts/Windows/Software/TrackMania Nations Forever/Manage.ps1 @@ -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); } diff --git a/scripts/Windows/Software/TrackMania United Forever/Manage.ps1 b/scripts/Windows/Software/TrackMania United Forever/Manage.ps1 index d8f7cd8d..7878eb9a 100644 --- a/scripts/Windows/Software/TrackMania United Forever/Manage.ps1 +++ b/scripts/Windows/Software/TrackMania United Forever/Manage.ps1 @@ -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; diff --git a/scripts/Windows/Software/osu!/Manage.ps1 b/scripts/Windows/Software/osu!/Manage.ps1 index 3e780e10..46e0e188 100644 --- a/scripts/Windows/Software/osu!/Manage.ps1 +++ b/scripts/Windows/Software/osu!/Manage.ps1 @@ -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";