@ECHO OFF&(PUSHD "%~DP0")&(REG QUERY "HKU\S-1-5-19">NUL 2>&1)||(
powershell -Command "Start-Process '%~sdpnx0' -Verb RunAs"&&EXIT)

taskkill /f /im WSHelper* >NUL 2>NUL
taskkill /f /im PDFExpert* >NUL 2>NUL
taskkill /f /im PDFelement* >NUL 2>NUL

::清除万兴产品附加垃圾组件及开机启动项 WSHelper；
rd/s/q "%LocalAppData%\Wondershare\WSHelper" 2>NUL
rd/s/q "%AppData%\Wondershare\Wondershare Helper Compact" 2>NUL
IF NOT EXIST "%ProgramW6432%" (
rd/s/q "%CommonProgramFiles%\Wondershare\Wondershare Helper Compact"2>NUL
) ELSE (
rd/s/q "%CommonProgramW6432%\Wondershare\Wondershare Helper Compact"2>NUL
rd/s/q "%CommonProgramFiles(x86)%\Wondershare\Wondershare Helper Compact"2>NUL)
reg delete "HKCU\Software\Wondershare\Wondershare Helper Compact" /f >NUL 2>NUL
reg delete "HKLM\SOFTWARE\Wondershare\Wondershare Helper Compact" /f >NUL 2>NUL
reg delete "HKLM\SOFTWARE\WOW6432Node\Wondershare\Wondershare Helper Compact" /f >NUL 2>NUL
reg delete "HKCU\Software\Microsoft\Windows\CurrentVersion\Run" /f /v "Wondershare Studio" >NUL 2>NUL
reg delete "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" /f /v "Wondershare Helper Compact.exe" >NUL 2>NUL
reg delete "HKCU\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Run" /f /v "WSVCUUpdateHelper.exe" >NUL 2>NUL
reg delete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" /f /v "WSVCUUpdateHelper.exe" >NUL 2>NUL
reg delete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" /f /v "Wondershare Helper Compact.exe" >NUL 2>NUL
reg delete "HKLM\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Run" /f /v "Wondershare Helper Compact.exe" >NUL 2>NUL

::移除掉PDF关联
FileAssociation.exe /c .pdf "%~dp0PDFExpert.exe" >NUL 2>NUL

::移除万兴打印机
start /b /wait "" "%~dp0WSPrtSetup\WSPrtSetup.exe" /dvrname "Wondershare PDF Expert" /prtname "Wondershare PDF Expert" /monname "Wondershare PDF Expert Monitor" /monport "Wondershare PDF Expert Monitor Port" /monfile "%~dp0WSPrtSetup\PEExpertPrinterMonitor.dll" /u

::清除系统文件残留
del/q "%WinDir%\System32\TWAINDSM32.msm" >NUL 2>NUL
del/q "%WinDir%\System32\PEExpertPrinterMonitor.dll" >NUL 2>NUL
del/q "%WinDir%\System32\spool\drivers\x64\3\PDFCREAT.BPD" >NUL 2>NUL
del/q "%WinDir%\System32\spool\drivers\x64\3\PDFCREAT.PPD" >NUL 2>NUL
rd/s/q "%AppData%\Wondershare\PDFExpert" 2>NUL
rd/s/q "%LOCALAPPDATA%\Wondershare"2>NUL
rd/s/q "%LOCALAPPDATA%\PDFExpert"2>NUL
rd/s/q "%ProgramData%\PDFExpert" 2>NUL
rd/s/q "%Public%\Documents\Wondershare" 2>NUL
del /q "%Public%\Desktop\万兴PDF专家.lnk" >NUL 2>NUL
del /q "%UserProfile%\Desktop\万兴PDF专家.lnk" >NUL 2>NUL

::清除注册表键值残留
reg delete "HKCR\.fdf\OpenWithList\PDFExpert.exe" /f >NUL 2>NUL
reg delete "HKCR\.pdf\OpenWithList\PDFExpert.exe" /f >NUL 2>NUL
reg delete "HKCR\Applications\PDFExpert.exe" /f >NUL 2>NUL
reg delete "HKCR\WondersharePDF.Document8"  /f >NUL 2>NUL
reg delete "HKCR\CLSID\{7561CFCF-E2B1-478B-9595-2B029D2418E8}" /f >NUL 2>NUL
reg delete "HKCR\SystemFileAssociations\.pdf\Shell\WondersharePDFExpert" /f  >NUL 2>NUL
reg delete "HKLM\SOFTWARE\PEPrinter" /f >NUL 2>NUL
reg delete "HKLM\SOFTWARE\Classes\wspe8" /f >NUL 2>NUL
reg delete "HKLM\Software\Wondershare\WAF" /f >NUL 2>NUL
reg delete "HKLM\Software\Wondershare\5387" /f >NUL 2>NUL
reg delete "HKLM\Software\Wondershare\PDFExpert" /f >NUL 2>NUL
reg delete "HKCU\Software\Wondershare\PDFExpert" /f >NUL 2>NUL
reg delete "HKCU\SOFTWARE\Wondershare\PeShellExt" /f >NUL 2>NUL
reg delete "HKLM\Software\Wow6432Node\Wondershare\WAF" /f >NUL 2>NUL
reg delete "HKLM\SOFTWARE\Classes\PEShellExt.PeContextMenuExtension" /f >NUL 2>NUL
reg delete "HKLM\Classes\*\shellex\ContextMenuHandlers\PeContextMenuExtension" /f >NUL 2>NUL
reg delete "HKLM\SOFTWARE\Classes\CLSID\{098A124A-AA1C-38C8-A65E-D1199A14516A}" /f >NUL 2>NUL
reg delete "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.fdf"  /f >NUL 2>NUL
reg delete "HKLM\Software\Classes\WondersharePDF.Document8" /f >NUL 2>NUL
reg delete "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /f /v "TMPDIR" >NUL 2>NUL
reg delete "HKLM\Software\Classes\SystemFileAssociations\.pdf\Shell\WondersharePDFExpert" /f >NUL 2>NUL
reg delete "HKLM\Software\Classes\SystemFileAssociations\.pdf\Shell\WondersharePDFExpertPrint" /f >NUL 2>NUL

ECHO.&ECHO 完成 &TIMEOUT /t 2 >NUL&EXIT