Skip to content

Commit 22c22c2

Browse files
Update setup.ps1
1 parent eea7f7c commit 22c22c2

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

setup.ps1

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -512,20 +512,26 @@ public class Wallpaper
512512
} until ($PGram -notmatch "\S")
513513
}
514514
5 { # Uninstall programs
515-
Write-Output "`nNot done yet!!`n" -ForegroundColor Yellow
515+
Write-Outpt "" # For consistant formatting
516516
$PROGRAMS = Get-ChildItem -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall, HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall, HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall | Get-ItemProperty | Select-Object -Property DisplayName, UninstallString
517+
# List installed programs
517518
$PgListNum = 0
518519
$PROGRAMS.DisplayName | ForEach-Object {
519520
if ($_ -match "\S") {
520521
Write-Output "$PglistNum. $_"
521522
}
522523
$PgListNum += 1
523524
}
524-
$UninsNum = Read-Host "Select the number of the program you wish to uninstall, or leave blank to exit"
525-
if ($UninsNum -match "\S" -or $UninsNum -in 0..($PgListNum-1)) {
525+
# Ask which program to uninstall
526+
$UninsNum = Read-Host "`nSelect the number of the program you wish to uninstall, or leave blank to exit"
527+
if ($UninsNum -match "\S" -and $UninsNum -in 0..($PgListNum-1)) {
526528
$UninstallString = $PROGRAMS.UninstallString[$UninsNum]
527529
$UninstallString = $UninstallString -replace '"',''
528-
Invoke-Expression "$UninstallString"
530+
try {
531+
Invoke-Expression "$UninstallString"
532+
} catch {
533+
Start-Process "$UninstallString"
534+
}
529535
} else {
530536
Write-Output "`nCanceled`n" -ForegroundColor Magenta
531537
}

0 commit comments

Comments
 (0)