@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 FoxitReader* >NUL 2>NUL
rd /s /q "%AppData%\Foxit Software"2>NUL

::移除福昕升级服务项
reg delete "HKCU\Software\Foxit Software\Foxit Reader 10.0" /F>NUL 2>NUL
sc stop FoxitReaderUpdateService >NUL 2>NUL&sc delete FoxitReaderUpdateService >NUL 2>NUL
::设置启动为简体中文
reg add "HKCU\Software\Foxit Software\Foxit Reader 10.0\Preferences\Languages" /f /v "nChooseLan" /d "1" >NUL 2>NUL
reg add "HKCU\Software\Foxit Software\Foxit Reader 10.0\Preferences\Languages" /f /v "LangID" /d "49007d" >NUL 2>NUL
::取消首次提示注册弹窗（已硬改程序移除）
reg add "HKCU\Software\Foxit Software\Foxit Reader 10.0\Preferences\Registration" /f /v "bShowRegisterDlg" /d "0" >NUL 2>NUL
::选项常规-取消广告条项（已硬改程序移除）
reg add "HKCU\Software\Foxit Software\Foxit Reader 10.0\Preferences\General" /f /v "bShowAdvertisement" /d "0" >NUL 2>NUL
::选项常规-禁用PDF互联（该功能组件已移除）
reg add "HKCU\Software\Foxit Software\Foxit Reader 10.0\ConnectedPDF" /f /v "DisablecPDF" /d "1" >NUL 2>NUL
::选项常规-取消收集数据改善体验
reg add "HKCU\Software\Foxit Software\Foxit Reader 10.0\Preferences\General" /f /v "bCollectData" /d "0" >NUL 2>NUL
::关闭安全阅读模式
reg add "HKLM\SOFTWARE\Foxit Software\Foxit Reader" /f /v "bSafeMode"  /d "0" >NUL 2>NUL
reg add "HKCU\Software\Foxit Software\Foxit Reader 10.0\Preferences\Trust Manager" /f /v "bSafeMode" /d "0" >NUL 2>NUL
::标记软件安装位置
reg add "HKCR\.pdf\OpenWithProgids" /f /v "URL Protocol"  /d "" >NUL 2>NUL
reg add "HKCR\.pdf\OpenWithProgids" /f /ve  /d "URL:FoxitReader Protoco" >NUL 2>NUL
reg add "HKCR\.pdf\OpenWithProgids" /f /v "FoxitReader.Document" /t REG_BINARY /d "" >NUL 2>NUL
reg add "HKLM\SOFTWARE\Foxit Software\Foxit Reader" /f /v "Edition"  /d "0" >NUL 2>NUL
reg add "HKLM\SOFTWARE\Foxit Software\Foxit Reader" /f /v "InstallPath"  /d "%~dp0\" >NUL 2>NUL

::创建桌面快捷方式
mshta VBScript:Execute("Set a=CreateObject(""WScript.Shell""):Set b=a.CreateShortcut(a.SpecialFolders(""Desktop"") & ""\福昕阅读器.lnk""):b.TargetPath=""%~sdp0FoxitReader.exe"":b.WorkingDirectory=""%~sdp0"":b.Save:close")

:Begin
CLS&ECHO.&ECHO 处理完成, 以下选项自选：
ECHO.&ECHO 1、设置默认PDF阅读器+缩略图外壳
ECHO.&ECHO 2、注册在浏览器打开PDF文件的插件
CHOICE /C 12 /N >NUL 2>NUL

IF "%ERRORLEVEL%"=="2" (
  IF NOT EXIST "%ProgramW6432%" (
    regsvr32 /s "plugins\FoxitReaderBrowserAx.dll"
    ) ELSE (
    regsvr32 /s "plugins\FoxitReaderBrowserAx.dll"
    regsvr32 /s "plugins\FoxitReaderBrowserAx64.dll"
    )
  start "" /min /wait "%~dp0FoxitReader.exe" /displayinbrowser
  CLS&ECHO.&ECHO 完成 &TIMEOUT /t 2 >NUL&GOTO Begin
)

IF "%ERRORLEVEL%"=="1" (
  del /f/q "%LocalAppData%\Microsoft\Windows\Explorer\*.db" >NUL 2>NUL
  del /f/q "%UserProfile%\AppData\Local\*.db" >NUL 2>NUL
  start "" /min /wait "%~dp0FoxitReader.exe" /register
    IF NOT EXIST "%ProgramW6432%" (
      regsvr32 /s "Shell Extensions\FoxitPrevHndlr.dll"
      regsvr32 /s "Shell Extensions\FoxitThumbnailHndlr_x86.dll"
      ) ELSE (
      regsvr32 /s "Shell Extensions\FoxitPrevHndlr.dll"
      regsvr32 /s "Shell Extensions\FoxitThumbnailHndlr_x64.dll"
      )
  start "" /min /wait "%~dp0Shell Extensions\FoxitPreviewhost.exe" /regserver
  CLS&ECHO.&ECHO 完成 &TIMEOUT /t 2 >NUL&GOTO Begin
)