Skip to content
Snippets Groups Projects
Commit 2c5bde13 authored by icommonsCRC's avatar icommonsCRC
Browse files

Upload New File

parent 34e1f086
Branches
No related tags found
No related merge requests found
# Ensure you are running this script with administrator privileges.
# List of applications to uninstall
$applications = @(
# Applications available via PatchMyPC
"dotPDN.PaintDotNet",
"notepad++.notepad++",
"PuTTY.PuTTY",
"Posit.RStudio",
"Microsoft.VisualStudioCode",
"VideoLAN.VLC",
"Mozilla.Firefox",
"WiresharkFoundation.Wireshark",
"WinSCP.WinSCP",
"7zip.7zip",
"HandBrake.HandBrake",
"OBSProject.OBSStudio",
# Applications to uninstall manually or with winget
"Zoom.Zoom",
"JetBrains.IntelliJIDEA.Community",
"AivarAnnamaa.Thonny",
"Insecure.Nmap",
"JetBrains.PyCharm.Community"
)
# Function to check if an application is installed
function Test-ApplicationInstalled {
param (
[string]$AppId
)
$listResult = winget list --id $AppId --accept-source-agreements 2>&1
return $listResult -like "*$AppId*"
}
# Function to prompt for confirmation
function Get-UserConfirmation {
param (
[string]$Message
)
$response = Read-Host -Prompt "$Message (y/n)"
return $response.ToLower() -eq 'y'
}
# Add a safety prompt at the beginning
Write-Host "This script will attempt to uninstall the following applications:" -ForegroundColor Yellow
$applications | ForEach-Object { Write-Host " - $_" -ForegroundColor Cyan }
Write-Host ""
if (-not (Get-UserConfirmation "Do you want to proceed with the uninstallation?")) {
Write-Host "Uninstallation cancelled by user." -ForegroundColor Yellow
exit
}
# Counter for tracking progress
$totalApps = $applications.Count
$currentApp = 0
# Iterate through the applications and uninstall each
foreach ($app in $applications) {
$currentApp++
Write-Host "`nProcessing ($currentApp/$totalApps): $app" -ForegroundColor Yellow
try {
# Check if the application is installed
if (Test-ApplicationInstalled -AppId $app) {
# Prompt for confirmation for each application
if (Get-UserConfirmation "Do you want to uninstall $app?") {
Write-Host "Uninstalling $app..." -ForegroundColor Green
winget uninstall --id $app --silent --accept-source-agreements
# Verify the uninstallation
if (-not (Test-ApplicationInstalled -AppId $app)) {
Write-Host "$app uninstalled successfully!" -ForegroundColor Green
} else {
Write-Host "Warning: $app might not have been fully uninstalled. Please check manually." -ForegroundColor Yellow
}
} else {
Write-Host "Skipping $app..." -ForegroundColor Cyan
}
} else {
Write-Host "$app is not installed." -ForegroundColor Cyan
}
} catch {
Write-Host "Failed to uninstall $app. Error: $_" -ForegroundColor Red
}
}
Write-Host "`nUninstallation process completed!" -ForegroundColor Green
Write-Host "Please check the output above for any warnings or errors." -ForegroundColor Yellow
# Optional: Generate a summary
$remainingApps = $applications | Where-Object { Test-ApplicationInstalled -AppId $_ }
if ($remainingApps) {
Write-Host "`nThe following applications may still be installed:" -ForegroundColor Yellow
$remainingApps | ForEach-Object { Write-Host " - $_" -ForegroundColor Cyan }
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment