forked from hackofalltrades/msiuninstaller
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathautouninstall.ps1
More file actions
62 lines (28 loc) · 1.77 KB
/
autouninstall.ps1
File metadata and controls
62 lines (28 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
### Usage autouninstall.ps1 -appname "Apache Tomcat"
### Use the below line to list all apps to determine how the app is named in the registry.
### Get-ChildItem -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall, HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall | Get-ItemProperty | Select-Object DisplayName
param ($appname)
if (!$appname) {Write-Host "Please enter a valid app name"
break}
$apps = (Get-ChildItem -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall, HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall |
Get-ItemProperty |
Where-Object {($_.DisplayName -match "$appname")})
foreach ($app in $apps) {
if (!$app) { Write-Host "No additional apps found."}
if ($app) {
Write-Host "Vulnerable Apps Found:"
$name = $app.displayname
Write-Host "$name Detected"
$uninstall = $app.UninstallString
Write-Host "Attempting install running $uninstall /q /n /norestart"
$uninstallcmd = $uninstall + " /qn /norestart"
$guid = $uninstall -replace "MsiExec.exe /X",""
Start-Process -FilePath "$env:systemroot\system32\msiexec.exe" -ArgumentList "/x$guid /qn /norestart /l*v appappremoval.log" -Wait
Write-Host "Verifying uninstall..."
$installed = Get-ChildItem -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall, HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall |
Get-ItemProperty |
Where-Object {($_.DisplayName -match "$name")}
if (!$installed) {Write-Host "Uninstall of $name Successful"}
else {Write-Host "Uninstall of $name Failed."}
}
}