@ECHO OFF
PUSHD %~DP0
If "%PROCESSOR_ARCHITECTURE%"=="AMD64" (Set a=%SystemRoot%\SysWOW64) Else (Set b=%SystemRoot%\system32)
Md "%b%\test_permissions" 2>nul||(Echo 请使用右键管理员身份运行&&Pause >nul&&Exit)
Rd "%b%\test_permissions"
SetLocal EnableDelayedExpansion

taskkill /f /im IDM* >NUL 2>NUL
taskkill /f /im IEMon* >NUL 2>NUL

Net Stop IDMWFP >NUL 2>NUL & Net1 Stop IDMWFP >NUL 2>NUL

If Exist Uninstall.exe Uninstall.exe -instdriv

reg add HKCU\Software\DownloadManager /f /v ToolbarStyle /d "Faenza" >NUL
reg add HKCU\Software\DownloadManager /f /v idmvers /d "v6.23b1 Full" >NUL
reg add HKCU\Software\DownloadManager /f /v LaunchOnStart /t REG_DWORD /d 0 >NUL
::reg add HKCU\Software\DownloadManager /f /v FSSettingsChecked /t REG_DWORD /d 1 >NUL
reg add HKCU\Software\DownloadManager /f /v LanguageID /t REG_DWORD /d "0x00000804" >NUL

If Exist "%b%" regsvr32 /s IDMIECC.dll
If Exist "%a%" regsvr32 /s IDMIECC64.dll

If Exist "%b%" regsvr32 /s IDMGetAll.dll
If Exist "%a%" regsvr32 /s IDMGetAll64.dll

Start /Wait /B "" "%~dp0idmBroker.exe" -RegServer

If Exist "%b%" regsvr32 /s downlWithIDM.dll
If Exist "%a%" regsvr32 /s downlWithIDM64.dll

Start /Wait /B "" "%~dp0IDMan.exe" /rtr /isupdt /setlngid 2052 /fulllngfile idm_chn2.lng

If Exist Uninstall.exe Uninstall.exe -instdriv

Rundll32 setupapi.dll,InstallHinfSection DefaultInstall 128 .\idmwfp.inf

Net Start IDMWFP >NUL 2>NUL & Net1 Start IDMWFP >NUL 2>NUL

If Exist Uninstall.exe Uninstall.exe -uninsttdi

If Exist "%b%" regsvr32 /s IDMShellExt.dll
If Exist "%a%" regsvr32 /s IDMShellExt64.dll

If Exist "%b%" regsvr32 /s IDMIECC.dll
If Exist "%a%" regsvr32 /s IDMIECC64.dll

If Exist "%b%" regsvr32 /s IDMGetAll.dll
If Exist "%a%" regsvr32 /s IDMGetAll64.dll

If Exist "%b%" regsvr32 /s downlWithIDM.dll
If Exist "%a%" regsvr32 /s downlWithIDM64.dll

start /wait /B "" "%~dp0IEMonitor.exe"
If Exist "%a%" start /wait /B "" "%~dp0IDMIntegrator64.exe" -runcm

ECHO.&ECHO.完成! 是否创建桌面快捷方式？
ECHO.&ECHO.是请按任意键，否就直接关闭！&PAUSE >NUL 2>NUL
mshta VBScript:Execute("Set a=CreateObject(""WScript.Shell""):Set b=a.CreateShortcut(a.SpecialFolders(""Desktop"") & ""\IDM.lnk""):b.TargetPath=""%~dp0IDMan.exe"":b.WorkingDirectory=""%~dp0"":b.Save:close")&ECHO.&ECHO.完成! &PAUSE >NUL 2>NUL