@ECHO OFF & PUSHD "%CD%" && CD /D "%~DP0"
>NUL 2>&1 REG.exe query "HKU\S-1-5-19" || (
    ECHO SET UAC = CreateObject^("Shell.Application"^) > "%TEMP%\Getadmin.vbs"
    ECHO UAC.ShellExecute "%~f0", "%1", "", "runas", 1 >> "%TEMP%\Getadmin.vbs"
    "%TEMP%\Getadmin.vbs"
    DEL /f /q "%TEMP%\Getadmin.vbs" 2>NUL
    Exit /b
)

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

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 "%PROCESSOR_ARCHITECTURE%"=="x86" reg add "HKLM\Software\Wondershare\Wondershare PDFelement 7" /f /v InstallPath /d "%~dp0\" >NUL 2>NUL
if "%PROCESSOR_ARCHITECTURE%"=="x86" reg add "HKLM\Software\Wondershare\Wondershare PDFelement 7" /f /v appsetuppath /d "%~dp0\" >NUL 2>NUL
if "%PROCESSOR_ARCHITECTURE%"=="x86" reg add "HKLM\Software\PEPrinter\Wondershare PDFelement Monitor" /f /v InstallName /d "%~dp0PDFelement.exe" >NUL 2>NUL
if "%PROCESSOR_ARCHITECTURE%"=="AMD64" reg add "HKLM\Software\Wow6432Node\Wondershare\Wondershare PDFelement 7" /f /v InstallPath /d "%~dp0\" >NUL 2>NUL
if "%PROCESSOR_ARCHITECTURE%"=="AMD64" reg add "HKLM\Software\Wow6432Node\Wondershare\Wondershare PDFelement 7" /f /v appsetuppath /d "%~dp0\" >NUL 2>NUL
if "%PROCESSOR_ARCHITECTURE%"=="AMD64" reg add "HKLM\Software\Wow6432Node\PEPrinter\Wondershare PDFelement Monitor" /f /v InstallName /d "%~dp0PDFelement.exe" >NUL 2>NUL

if "%PROCESSOR_ARCHITECTURE%"=="x86" reg add "HKLM\Software\Wondershare\Wondershare PDFelement 7" /f /v Version /d "7.5.1.4782" >NUL 2>NUL
if "%PROCESSOR_ARCHITECTURE%"=="x86" reg add "HKLM\Software\Wondershare\Wondershare PDFelement 7" /f /v InstallPath /d "%~dp0\" >NUL 2>NUL
if "%PROCESSOR_ARCHITECTURE%"=="AMD64" reg add "HKLM\Software\Wow6432Node\Wondershare\Wondershare PDFelement 7" /f /v InstallPath /d "%~dp0\" >NUL 2>NUL
if "%PROCESSOR_ARCHITECTURE%"=="AMD64" reg add "HKLM\Software\Wow6432Node\Wondershare\Wondershare PDFelement 7" /f /v Version /d "7.5.0.4782" >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  【老殁 www.Laomo.me 专注分享 始于2010年】
Echo.&Echo  完成，以下自选:
Echo.&Echo  1、设置为PDF默认程序
Echo.&Echo  2、添加PDF右键菜单项
echo:  
choice /c:1234 /N /M " 输入数字选择: "
if %errorlevel%==1 Goto Associate
if %errorlevel%==2 Goto AddMenuExt
:Associate
start /wait /B FileAssociation.exe /InstallFileAssociate >NUL 2>NUL
SET E=完成!&GOTO MSGBOX
: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
SET E=完成!【老殁 www.Laomo.me 专注分享 始于2010年】 &GOTO MSGBOX
:MsgBox
if "%1"=="" mshta VBScript:MsgBox("%e%",vbSystemModal,"")(close)&Cls&Goto Menu