@ECHO OFF&PUSHD %~DP0 &TITLE 绿化卸载
mode con cols=36 lines=20
>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 Xshell* >NUL 2>NUL
:Menu
Cls
@ echo.
@ echo.　　　　　   菜 单 选 项
@ echo. 绿化  请输 → 1  
@ echo. 
@ echo. 卸载  请输 → 2     
@ echo.   
set /p zero=请输入数字按回车：
if /i "%zero%"=="1" Goto Setup
if /i "%zero%"=="2" Goto Uninst
echo.&echo 输入无效，请重新输入！ 
PAUSE >NUL && CLS && GOTO Menu

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

::清理之前残留的注册表类标识键值和假序列号
reg delete HKCU\Software\DownloadManager /v scansk /f>NUL 2>NUL
reg delete HKCU\Software\DownloadManager /v tvfrdt /f>NUL 2>NUL
reg delete HKCU\Software\DownloadManager /v CheckUpdtVM /f>NUL 2>NUL
reg delete HKCU\Software\DownloadManager /v LName /f>NUL 2>NUL
reg delete HKCU\Software\DownloadManager /v FName /f>NUL 2>NUL
reg delete HKCU\Software\DownloadManager /v Email /f>NUL 2>NUL
reg delete HKCU\Software\DownloadManager /v Serial /f>NUL 2>NUL
reg delete "HKLM\SOFTWARE\Internet Download Manager" /f>NUL 2>NUL
reg delete "HKLM\SOFTWARE\Wow6432Node\Internet Download Manager" /f>NUL 2>NUL
reg delete HKCU\Software\Classes\CLSID\{07999AC3-058B-40BF-984F-69EB1E554CA7} /f>NUL 2>NUL
reg delete HKCU\Software\Classes\CLSID\{6DDF00DB-1234-46EC-8356-27E7B2051192} /f>NUL 2>NUL
reg delete HKCU\Software\Classes\CLSID\{D5B91409-A8CA-4973-9A0B-59F713D25671} /f>NUL 2>NUL
reg delete HKCU\Software\Classes\CLSID\{7B8E9164-324D-4A2E-A46D-0165FB2000EC} /f>NUL 2>NUL
reg delete HKCU\Software\Classes\CLSID\{5ED60779-4DE2-4E07-B862-974CA4FF2E9C} /f>NUL 2>NUL
reg delete HKLM\Software\Classes\CLSID\{07999AC3-058B-40BF-984F-69EB1E554CA7} /f>NUL 2>NUL
reg delete HKLM\Software\Classes\CLSID\{6DDF00DB-1234-46EC-8356-27E7B2051192} /f>NUL 2>NUL
reg delete HKLM\Software\Classes\CLSID\{D5B91409-A8CA-4973-9A0B-59F713D25671} /f>NUL 2>NUL
reg delete HKLM\Software\Classes\CLSID\{7B8E9164-324D-4A2E-A46D-0165FB2000EC} /f>NUL 2>NUL
reg delete HKLM\Software\Classes\CLSID\{5ED60779-4DE2-4E07-B862-974CA4FF2E9C} /f>NUL 2>NUL
reg delete HKCU\Software\Classes\Wow6432Node\CLSID\{7B8E9164-324D-4A2E-A46D-0165FB2000EC} /f>NUL 2>NUL
reg delete HKCU\Software\Classes\Wow6432Node\CLSID\{5ED60779-4DE2-4E07-B862-974CA4FF2E9C} /f>NUL 2>NUL
reg delete HKLM\Software\Classes\Wow6432Node\CLSID\{7B8E9164-324D-4A2E-A46D-0165FB2000EC} /f>NUL 2>NUL
reg delete HKLM\Software\Classes\Wow6432Node\CLSID\{5ED60779-4DE2-4E07-B862-974CA4FF2E9C} /f>NUL 2>NUL

:: Windows All
reg add HKCU\Software\DownloadManager /f /v ToolbarStyle /d "Glyfz 2016" >NUL
reg add HKCU\Software\DownloadManager /f /v idmvers /d "v6.32.8.2 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

@ECHO OFF
If exist "%Temp%\~djqotqb.reg" (
 Attrib -R -S -H "%Temp%\~djqotqb.reg"
 del /F /Q "%Temp%\~djqotqb.reg"
 If exist "%Temp%\~djqotqb.reg" (
  Echo Could not delete file "%Temp%\~djqotqb.reg"
  Pause
 )
)
> "%Temp%\~djqotqb.reg" ECHO Windows Registry Editor Version 5.00
>> "%Temp%\~djqotqb.reg" ECHO.
>> "%Temp%\~djqotqb.reg" ECHO [HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Internet Download Manager]
>> "%Temp%\~djqotqb.reg" ECHO "FName"="admin"
>> "%Temp%\~djqotqb.reg" ECHO "Serial"="WSWQ1-7CUV6-BKIB4-WLI4T"
>> "%Temp%\~djqotqb.reg" ECHO "LName"=""
>> "%Temp%\~djqotqb.reg" ECHO "Email"="admin@52pojie.cn"
>> "%Temp%\~djqotqb.reg" ECHO.
>> "%Temp%\~djqotqb.reg" ECHO [HKEY_LOCAL_MACHINE\SOFTWARE\Internet Download Manager]
>> "%Temp%\~djqotqb.reg" ECHO "FName"="admin"
>> "%Temp%\~djqotqb.reg" ECHO "Serial"="8NXL7-7T4QP-P8328-6O6HL"
>> "%Temp%\~djqotqb.reg" ECHO "LName"=""
>> "%Temp%\~djqotqb.reg" ECHO "Email"="admin@52pojie.cn"
START /WAIT REGEDIT /S "%Temp%\~djqotqb.reg"
DEL "%Temp%\~djqotqb.reg"


:: Windows 64-Bit
If "%PROCESSOR_ARCHITECTURE%"=="AMD64" regsvr32 /s IDMIECC64.dll
If "%PROCESSOR_ARCHITECTURE%"=="AMD64" regsvr32 /s IDMGetAll64.dll
If "%PROCESSOR_ARCHITECTURE%"=="AMD64" regsvr32 /s downlWithIDM64.dll

:: Windows 7/8/10
If Exist "%Public%" idmBroker.exe -RegServer

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

:: Windows 7/8/10
If Exist "%Public%" Uninstall.exe -instdriv

:: Windows 7/8/10
If Exist "%Public%" Rundll32 setupapi.dll,InstallHinfSection DefaultInstall 128 .\idmwfp.inf
:: Windows XP
If Not Exist "%Public%" Rundll32 setupapi.dll,InstallHinfSection DefaultInstall 128 .\idmtdi.inf

:: Windows 7/8/10
If Exist "%Public%" Net Start IDMWFP >NUL 2>NUL
:: Windows XP
If Not Exist "%Public%" Net Start idmtdi >NUL 2>NUL


CLS & ECHO.&ECHO 绿化完成，是否创建桌面快捷方式？
ECHO.&ECHO 是按任意键，否直接关闭窗口即可！&&PAUSE >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")
CLS && ECHO.&ECHO 创建完成，任意键返回！ &&PAUSE>NUL && CLS && GOTO MENU

:Uninst

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

If Exist "%Public%" Net Stop IDMWFP >NUL 2>NUL
If Not Exist "%Public%" Net Stop IDMTDI >NUL 2>NUL

If Exist "%Public%" Rundll32 setupapi.dll,InstallHinfSection DefaultUninstall 128 .\idmwfp.inf
If Not Exist "%Public%" Rundll32 setupapi.dll,InstallHinfSection DefaultUninstall 128 .\idmtdi.inf

If Exist "%WinDir%\SysWOW64" Regsvr32 /s /u IDMShellExt64.dll

rd/s/q "%AppData%\IDM"2>NUL
If Exist "%a%" rd/s/q "%ProgramData%\IDM" 2>NUL
rd/s/q "%AllUsersProfile%\Application Data\IDM"2>NUL
reg delete HKCU\Software\DownloadManager /v scansk /f>NUL 2>NUL
reg delete HKCU\Software\DownloadManager /v tvfrdt /f>NUL 2>NUL
reg delete HKCU\Software\DownloadManager /v CheckUpdtVM /f>NUL 2>NUL
reg delete HKCU\Software\DownloadManager /v LName /f>NUL 2>NUL
reg delete HKCU\Software\DownloadManager /v FName /f>NUL 2>NUL
reg delete HKCU\Software\DownloadManager /v Email /f>NUL 2>NUL
reg delete HKCU\Software\DownloadManager /v Serial /f>NUL 2>NUL
reg delete "HKLM\SOFTWARE\Internet Download Manager" /f>NUL 2>NUL
reg delete "HKLM\SOFTWARE\Wow6432Node\Internet Download Manager" /f>NUL 2>NUL
reg delete HKCU\Software\Classes\CLSID\{07999AC3-058B-40BF-984F-69EB1E554CA7} /f>NUL 2>NUL
reg delete HKCU\Software\Classes\CLSID\{6DDF00DB-1234-46EC-8356-27E7B2051192} /f>NUL 2>NUL
reg delete HKCU\Software\Classes\CLSID\{D5B91409-A8CA-4973-9A0B-59F713D25671} /f>NUL 2>NUL
reg delete HKCU\Software\Classes\CLSID\{7B8E9164-324D-4A2E-A46D-0165FB2000EC} /f>NUL 2>NUL
reg delete HKCU\Software\Classes\CLSID\{5ED60779-4DE2-4E07-B862-974CA4FF2E9C} /f>NUL 2>NUL
reg delete HKLM\Software\Classes\CLSID\{07999AC3-058B-40BF-984F-69EB1E554CA7} /f>NUL 2>NUL
reg delete HKLM\Software\Classes\CLSID\{6DDF00DB-1234-46EC-8356-27E7B2051192} /f>NUL 2>NUL
reg delete HKLM\Software\Classes\CLSID\{D5B91409-A8CA-4973-9A0B-59F713D25671} /f>NUL 2>NUL
reg delete HKLM\Software\Classes\CLSID\{7B8E9164-324D-4A2E-A46D-0165FB2000EC} /f>NUL 2>NUL
reg delete HKLM\Software\Classes\CLSID\{5ED60779-4DE2-4E07-B862-974CA4FF2E9C} /f>NUL 2>NUL
reg delete HKCU\Software\Classes\Wow6432Node\CLSID\{7B8E9164-324D-4A2E-A46D-0165FB2000EC} /f>NUL 2>NUL
reg delete HKCU\Software\Classes\Wow6432Node\CLSID\{5ED60779-4DE2-4E07-B862-974CA4FF2E9C} /f>NUL 2>NUL
reg delete HKLM\Software\Classes\Wow6432Node\CLSID\{7B8E9164-324D-4A2E-A46D-0165FB2000EC} /f>NUL 2>NUL
reg delete HKLM\Software\Classes\Wow6432Node\CLSID\{5ED60779-4DE2-4E07-B862-974CA4FF2E9C} /f>NUL 2>NUL
taskkill /f /im explorer.exe >NUL 2>NUL & start explorer
CLS && ECHO.&ECHO.卸载完成！是否备份个人设置？
ECHO.&ECHO.是按任意键，否直接关闭窗口！&&PAUSE >NUL 2>NUL
regedit /e "用户配置.reg" HKEY_CURRENT_USER\Software\DownloadManager >NUL 2>NUL
reg delete HKEY_CURRENT_USER\Software\DownloadManager /f>NUL 2>NUL
CLS && ECHO.&ECHO 卸载完成，任意键返回！ &&PAUSE >NUL && CLS && GOTO MENU