This commit is contained in:
2020-05-22 14:35:46 -04:00
parent c5b16d024c
commit 7907fe891b
15 changed files with 198 additions and 59 deletions
+24 -10
View File
@@ -24,29 +24,43 @@ $RegKeys = @(
)
## Find the most likely path to the TeamViewer uninstaller
If ( Test-Path "${Env:ProgramFiles(x86)}" ) {
If ( Test-Path "${Env:ProgramFiles(x86)}" )
{
$INSTALLDIR = $(Get-ItemProperty -Path "HKLM:\SOFTWARE\WOW6432Node\TeamViewer").InstallationDirectory
} Else {
}
Else
{
$INSTALLDIR = $(Get-ItemProperty -Path "HKLM:\SOFTWARE\TeamViewer").InstallationDirectory
}
## Kill all running instances of TeamViewer
Get-Process | Where { $_.Name -like "*TeamViewer*" }
If ( Test-Path "${INSTALLDIR}\uninstall.exe" ) { Start-Process "${INSTALLDIR}\uninstall.exe" -ArgumentList "/S" -Wait }
If ( Test-Path "${INSTALLDIR}\uninstall.exe" )
{ Start-Process "${INSTALLDIR}\uninstall.exe" -ArgumentList "/S" -Wait }
## Loop through each path in $UninstallerPaths and test if each one exists.
## If a path exists, silently run the uninstaller and then delete the directory.
Foreach ($uninstaller in $UninstallerPaths) {
if ( Test-Path "${uninstaller}" ) { Start-Process "${uninstaller}" -ArgumentList "/S" -Wait }
if ( Test-Path "${(Get-Item $uninstaller).Directory.FullName}" ) { Remove-Item "${(Get-Item $uninstaller).Directory.FullName}" -Recurse }
Foreach ($uninstaller in $UninstallerPaths)
{
If ( Test-Path "${uninstaller}" )
{
## Run the uninstaller
Start-Process "${uninstaller}" -ArgumentList "/S" -Wait
## Remove the directory
$dirname = $(Get-Item $uninstaller).Directory.FullName
Remove-Item "${dirname}" -Recurse -ErrorAction SilentlyContinue
}
}
## Remove each registry key in $RegKeys
Foreach ($key in $RegKeys) {
if ( Test-Path $key ) { Remove-Item $key -Recurse }
Foreach ($key in $RegKeys)
{
If ( Test-Path $key ) { Remove-Item $key -Recurse }
}
## Remove the TeamViewer service
Start-Process "sc.exe" -ArgumentList "delete TeamViewer"
Start-Process "sc.exe" -ArgumentList "delete TeamViewer_Service"
Start-Process "sc.exe" -ArgumentList "delete TeamViewer" -Wait
Start-Process "sc.exe" -ArgumentList "delete TeamViewer_Service" -Wait