Skip to content

Instantly share code, notes, and snippets.

@dpo007
Last active April 29, 2022 17:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dpo007/86d10ad0678860e8047cd4dfbf9a0666 to your computer and use it in GitHub Desktop.
Save dpo007/86d10ad0678860e8047cd4dfbf9a0666 to your computer and use it in GitHub Desktop.
PowerShell :: Scrubs Foxit's PhantomPDF editor off a machine. Created to help make way for upgrade to "Foxit PDF Editor".
<#
Foxit PhantomPDF Remover/Cleaner
V1.5 - DPO - Apr. 2022
#>
param (
[switch]$LeaveUUID
)
Write-Host 'Looking for Foxit PhantomPDF installs...'
$foxitPhantom = Get-Package 'Foxit Phan*' -AllVersions -ErrorAction SilentlyContinue
if ($foxitPhantom) {
try {
Write-Host 'Removing Foxit PhantomPDF installs...'
$foxitPhantom | Uninstall-Package -Force
} catch {
Write-Host ('Failure uninstalling Foxit PhantomPDF. Aborting. Error: {0}' -f $_.Exception.Message )
exit 666
}
}
if (!$LeaveUUID) {
Write-Host 'Looking for Foxit PDF Editor installs...'
$foxitPDFEditor = Get-Package 'Foxit PDF Editor' -AllVersions -ErrorAction SilentlyContinue
if ($foxitPDFEditor) {
Write-Host 'Found Foxit PDF Editor installed.'
$LeaveUUID = $true
}
}
Write-Host 'Removing left-over Foxit PhantomPDF files/folders/registry entries...'
Remove-Item 'C:\Program Files (x86)\Foxit Software\Foxit PhantomPDF' -Recurse -Force -ErrorAction SilentlyContinue
Remove-Item 'C:\Users\*\AppData\Local\Foxit PhantomPDF' -Recurse -Force -ErrorAction SilentlyContinue
Remove-Item 'C:\Users\*\Desktop\Foxit PhantomPDF.lnk' -Recurse -Force -ErrorAction SilentlyContinue
Remove-Item 'HKLM:\SOFTWARE\Foxit Software\Foxit PhantomPDF*' -Recurse -Force -ErrorAction SilentlyContinue
Remove-Item 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Print\PrinterMigrationEx\Foxit PhantomPDF Printer' -Recurse -Force -ErrorAction SilentlyContinue
Remove-Item 'HKLM:\SOFTWARE\RegisteredApplications\Foxit PhantomPDF*' -Recurse -Force -ErrorAction SilentlyContinue
Remove-Item 'HKLM:\SOFTWARE\Synaptics\SynTPEnh\OSD\TouchPad\AppProfiles\Foxit PhantomPDF*' -Recurse -Force -ErrorAction SilentlyContinue
Remove-Item 'HKLM:\SOFTWARE\WOW6432Node\Foxit Software\Foxit PhantomPDF*' -Recurse -Force -ErrorAction SilentlyContinue
if ($LeaveUUID) {
Write-Host 'Leaving "HKLM:\SOFTWARE\WOW6432Node\Foxit Software\UUID" as-is.'
} else {
Remove-ItemProperty -Path 'HKLM:\SOFTWARE\WOW6432Node\Foxit Software\' -Name 'UUID'-Force -ErrorAction SilentlyContinue
}
Remove-Item 'registry::HKEY_USERS\*\Software\Foxit Software\Foxit PhantomPDF*' -Recurse -Force -ErrorAction SilentlyContinue
$paths = $null
$paths = Get-ChildItem -Recurse 'HKLM:\SOFTWARE\Classes\Installer\Products' | Get-ItemProperty | Where-Object { $_ -match 'Foxit PhantomPDF' } | Select-Object ProductIcon | Select-Object -ExpandProperty ProductIcon
foreach ($path in $paths) {
$path = split-path $path
Write-Host ('Removing {0}...' -f $path)
if (Test-Path $path) {
Remove-Item $path -Recurse -Force -ErrorAction SilentlyContinue
}
}
$paths = $null
$paths = Get-ChildItem -Recurse 'HKLM:\SOFTWARE\Classes\Installer\Products' | Get-ItemProperty | Where-Object { $_ -match 'Foxit PhantomPDF' } | Select-Object PSPath | Select-Object -ExpandProperty PSPath
foreach ($path in $paths) {
$path = $path -replace 'Microsoft.PowerShell.Core\\Registry::HKEY_LOCAL_MACHINE\\','HKLM:\'
Write-Host ('Removing {0}...' -f $path)
if (Test-Path $path) {
Remove-Item $path -Recurse -Force -ErrorAction SilentlyContinue
}
}
$paths = $null
$paths = Get-ChildItem -Recurse 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Group Policy\AppMgmt\' | Get-ItemProperty | Where-Object { $_ -match 'Foxit PhantomPDF' } | Select-Object PSPath | Select-Object -ExpandProperty PSPath
foreach ($path in $paths) {
$path = $path -replace 'Microsoft.PowerShell.Core\\Registry::HKEY_LOCAL_MACHINE\\','HKLM:\'
Write-Host ('Removing {0}...' -f $path)
if (Test-Path $path) {
Remove-Item $path -Recurse -Force -ErrorAction SilentlyContinue
}
}
Write-Host 'Done.'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment