@ECHO OFF & PUSHD "%~DP0" && CD /D "%~DP0"
IF EXIST "%PUBLIC%" >NUL 2>&1 REG QUERY "HKU\S-1-5-19"
IF NOT %ERRORLEVEL% EQU 0 (
IF EXIST "%PUBLIC%" powershell.exe -windowstyle hidden -noprofile "Start-Process '%~dpnx0' -Verb RunAs"
EXIT
)

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

::清理万兴产品垃圾组件及开机启动项 Wondershare Helper Compact；
rmdir/s/q "%LocalAppData%\Wondershare" 2>NUL
rmdir/s/q "%AllUsersProfile%\Application Data\Wondershare" 2>NUL
rmdir/s/q "%AppData%\Wondershare\Wondershare Helper Compact" 2>NUL
rmdir/s/q "%CommonProgramFiles%\Wondershare\Wondershare Helper Compact" 2>NUL
rmdir/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 "HKLM\SOFTWARE\Classes\WSCustomerServicePlatform.CustomerService" /f >NUL 2>NUL
reg delete "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" /f /v "Wondershare Helper Compact.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

rmdir/s/q "%ProgramData%\PDF Expert" 2>NUL
rmdir/s/q "%ProgramData%\PDFelement 7" 2>NUL
rmdir/s/q "%AppData%\Wondershare\PDFelement 7"2>NUL
rmdir/s/q "%AppData%\Wondershare\PDF Expert" 2>NUL
del/f/q "%temp%\FullUpdateConfig*.xml" >NUL 2>NUL
del/f/q "%temp%\PatchUpdateConfig*.xml" >NUL 2>NUL
del/f/q "%temp%\WhatsNewFile*.xml" >NUL 2>NUL
del/f/q "%temp%\pdfelement_*.exe" >NUL 2>NUL

::屏蔽后续更新提示及启动强制下载安装包行为!
md "%temp%\WhatsNewFile_万兴PDF专家.xml"2>NUL
md "%temp%\PatchUpdateConfig_万兴PDF专家.xml"2>NUL
md "%temp%\FullUpdateConfig_万兴PDF专家.xml"2>NUL
attrib +r +a +s +h +x "%temp%\WhatsNewFile_万兴PDF专家.xml" >NUL 2>NUL
attrib +r +a +s +h +x "%temp%\FullUpdateConfig_万兴PDF专家.xml" >NUL 2>NUL
attrib +r +a +s +h +x "%temp%\PatchUpdateConfig_万兴PDF专家.xml" >NUL 2>NUL

reg delete "HKLM\SOFTWARE\PDF Expert" /f >NUL 2>NUL
reg delete "HKLM\SOFTWARE\Wondershare\5387" /f >NUL 2>NUL
reg delete "HKLM\SOFTWARE\Wondershare\5239" /f >NUL 2>NUL
reg delete "HKLM\SOFTWARE\WOW6432Node\Wondershare\5387" /f >NUL 2>NUL
reg delete "HKLM\SOFTWARE\WOW6432Node\Wondershare\5239" /f >NUL 2>NUL
reg delete "HKLM\SOFTWARE\Wondershare\Wondershare PDFelement 7" /f >NUL 2>NUL
reg delete "HKLM\SOFTWARE\Wow6432Node\Wondershare\Wondershare PDF Expert" /f >NUL 2>NUL
reg delete "HKLM\SOFTWARE\Wow6432Node\Wondershare\Wondershare PDFelement 7" /f >NUL 2>NUL

reg add "HKCR\wspe7" /f /v "URL Protocol" /d "" >NUL 2>NUL
reg add "HKCR\wspe7" /f /ve /d "Wondershare PDFelement" >NUL 2>NUL
reg add "HKCR\wspe7\shell\open\command" /f /ve /d "\"%~dp0PDFelement.exe\" \"%%1\"" >NUL 2>NUL


if /i %PROCESSOR_IDENTIFIER:~0,3%==x86 (
reg add "HKLM\Software\Wondershare\Wondershare PDFelement 7" /f /v "Version" /d "7.6.0.4878" >NUL 2>NUL
reg add "HKLM\Software\Wondershare\Wondershare PDFelement 7" /f /v "InstallPath" /d "%~dp0\" >NUL 2>NUL
reg add "HKLM\Software\Wondershare\Wondershare PDFelement 7" /f /v "InstallPath" /d "%~dp0\" >NUL 2>NUL
reg add "HKLM\Software\Wondershare\Wondershare PDFelement 7" /f /v "appsetuppath" /d "%~dp0\" >NUL 2>NUL
reg add "HKLM\Software\PEPrinter\Wondershare PDFelement Monitor" /f /v "InstallName" /d "%~dp0PDFelement.exe" >NUL 2>NUL
) else (
reg add "HKLM\Software\Wow6432Node\Wondershare\Wondershare PDFelement 7" /f /v "InstallPath" /d "%~dp0\" >NUL 2>NUL
reg add "HKLM\Software\Wow6432Node\Wondershare\Wondershare PDFelement 7" /f /v "Version" /d "7.6.0.4878" >NUL 2>NUL
reg add "HKLM\Software\Wow6432Node\Wondershare\Wondershare PDFelement 7" /f /v "InstallPath" /d "%~dp0\" >NUL 2>NUL
reg add "HKLM\Software\Wow6432Node\Wondershare\Wondershare PDFelement 7" /f /v "appsetuppath" /d "%~dp0\" >NUL 2>NUL
reg add "HKLM\Software\Wow6432Node\PEPrinter\Wondershare PDFelement Monitor" /f /v "InstallName" /d "%~dp0PDFelement.exe" >NUL 2>NUL
)

mshta VBScript:Execute("Set a=CreateObject(""WScript.Shell""):Set b=a.CreateShortcut(a.SpecialFolders(""Desktop"") & ""\万兴PDF专家.lnk""):b.TargetPath=""%~dp0PDFelement.exe"":b.WorkingDirectory=""%~dp0"":b.Save:close")

:Menu
Echo.&Echo  完成，以下自选:
Echo.&Echo  1、设置为PDF默认程序
Echo.&Echo  2、添加PDF右键菜单项
Echo.&Echo.
set /p a=输入数字按回车：
If Not "%a%"=="" Set a=%a:~0,1%
If "%a%"=="1" Goto Associate
If "%a%"=="2" Goto AddMenuExt
cls & Echo.&Echo 输入无效，重新输入！
PAUSE >NUL & CLS & GOTO Menu
:Associate
start /wait /B FileAssociation.exe /InstallFileAssociate >NUL 2>NUL
CLS&ECHO.&ECHO 完成，按任意键返回！&PAUSE >NUL & CLS & GOTO MENU
:AddMenuExt
reg add "HKCR\.fdf\OpenWithList\PDFelement.exe" /f /ve /d "" >NUL 2>NUL
reg add "HKCR\.pdf\OpenWithList\PDFelement.exe" /f /ve /d "" >NUL 2>NUL
reg add "HKCR\Applications\PDFelement.exe\Shell\Open\Command" /f /ve /d "\"%~dp0PDFelement.exe\" \"%%1\"" >NUL 2>NUL
reg add "HKCR\SystemFileAssociations\.pdf\Shell\WondersharePDFExpert" /f /ve /d "用万兴PDF编辑"  >NUL 2>NUL
reg add "HKCR\SystemFileAssociations\.pdf\Shell\WondersharePDFExpert\Command" /f /ve /d  "\"%~dp0PDFelement.exe\" \"%%1\"" >NUL 2>NUL
reg add "HKCR\WondersharePDF.Document7\DefaultIcon" /f /ve /d "\"%~dp0projectfile.ico\""  >NUL 2>NUL
reg add "HKCR\WondersharePDF.Document7\shell\open\command" /f /ve /d "\"%~dp0PDFelement.exe\" \"%%1\""  >NUL 2>NUL
CLS&ECHO.&ECHO 完成，按任意键返回！&PAUSE >NUL & CLS & GOTO MENU