Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
wingetScripts
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
icommonsCRC
wingetScripts
Commits
2c5bde13
Commit
2c5bde13
authored
6 months ago
by
icommonsCRC
Browse files
Options
Downloads
Patches
Plain Diff
Upload New File
parent
34e1f086
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
wingetUninstaller.ps1
+99
-0
99 additions, 0 deletions
wingetUninstaller.ps1
with
99 additions
and
0 deletions
wingetUninstaller.ps1
0 → 100644
+
99
−
0
View file @
2c5bde13
# 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
"
`n
Processing (
$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
"
`n
Uninstallation 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
"
`n
The following applications may still be installed:"
-ForegroundColor
Yellow
$remainingApps
|
ForEach-Object
{
Write-Host
" -
$_
"
-ForegroundColor
Cyan
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment