Auto-commit: 2025-10-31 08:58:35
This commit is contained in:
30
Uninstall-Apps-Script/readme.md
Normal file
30
Uninstall-Apps-Script/readme.md
Normal file
@@ -0,0 +1,30 @@
|
||||
Silent Uninstaller (PowerShell)
|
||||
|
||||
Removes installed apps by name using data from Windows **Uninstall** registry keys.
|
||||
Supports **MSI** (`msiexec /X {GUID}`) and **EXE** uninstallers with a custom silent switch.
|
||||
|
||||
## What it does
|
||||
- Searches in:
|
||||
- `HKCU\Software\...\Uninstall`
|
||||
- `HKLM\Software\...\Uninstall`
|
||||
- `HKLM\Software\Wow6432Node\...\Uninstall`
|
||||
- Detects MSI vs EXE uninstallers and runs them silently.
|
||||
- Logs each action to `C:\Windows\temp\uninstall.log`.
|
||||
|
||||
## Usage
|
||||
```powershell
|
||||
# Syntax
|
||||
Uninstall -AppName "<partial or full DisplayName>" [-Arg "<silent-args>"]
|
||||
|
||||
# Examples
|
||||
Uninstall -AppName "Firefox" -Arg "-ms"
|
||||
Uninstall -AppName "TeamViewer" # uses default /S
|
||||
Uninstall -AppName "AnyDesk"
|
||||
```
|
||||
|
||||
⚠️ Notes
|
||||
|
||||
- Run PowerShell **as Administrator**.
|
||||
- `-AppName` performs a **contains** match on `DisplayName` (may uninstall multiple apps if names overlap).
|
||||
- Silent switches vary by vendor; override with **`-Arg`** if needed.
|
||||
- MSI uninstalls run with `REBOOT=ReallySuppress /qn`, but a reboot may still be required.
|
||||
47
Uninstall-Apps-Script/uninstallapp.ps1
Normal file
47
Uninstall-Apps-Script/uninstallapp.ps1
Normal file
@@ -0,0 +1,47 @@
|
||||
function Uninstall {
|
||||
param (
|
||||
[Parameter(Mandatory=$true)] [string]$AppName,
|
||||
[Parameter(Mandatory=$false)] [string]$Arg = "/S"
|
||||
)
|
||||
|
||||
# Define uninstall keys
|
||||
$uninstallKeys = @(
|
||||
'HKCU:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*',
|
||||
'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*',
|
||||
'HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*'
|
||||
)
|
||||
|
||||
# Define the log file path
|
||||
$logFilePath = "C:\Windows\temp\uninstall.log"
|
||||
|
||||
# Fetch all keys
|
||||
$keys = Get-ChildItem -Path $uninstallKeys -ErrorAction SilentlyContinue
|
||||
|
||||
# Filter and uninstall the specified app
|
||||
$keys | Where-Object {
|
||||
$_.GetValue('DisplayName') -like "*$AppName*"
|
||||
} | ForEach-Object {
|
||||
$uninstallString = $_.GetValue('UninstallString')
|
||||
$uninstallApps = $_.GetValue('DisplayName')
|
||||
|
||||
if ($uninstallString -like "msiexec*" -and $uninstallString -like '*{*') {
|
||||
$uninstallString = "{$($uninstallString.split('{')[1])"
|
||||
|
||||
$logEntry = "$uninstallApps => msiexec.exe /X $uninstallString REBOOT=ReallySuppress /qn"
|
||||
Write-Host $logEntry
|
||||
Add-Content -Path $logFilePath -Value $logEntry
|
||||
Start-Process -FilePath "c:\windows\system32\msiexec.exe" -ArgumentList "/X $uninstallString REBOOT=ReallySuppress /qn" -Wait
|
||||
}
|
||||
if (($uninstallString -like "*.exe*") -and ($uninstallString -notlike "*msiexec*")) {
|
||||
$logEntry = "$uninstallApps => $uninstallString $Arg"
|
||||
Write-Host $logEntry
|
||||
Add-Content -Path $logFilePath -Value $logEntry
|
||||
Start-Process -FilePath "$uninstallString" -ArgumentList "$Arg" -Wait
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Uninstall -AppName "Firefox" -Arg "-ms"
|
||||
Uninstall -AppName "Teamviewer"
|
||||
Uninstall -AppName "AnyDesk"
|
||||
Reference in New Issue
Block a user