:: Re-launch the script with x64 process if it was initiated by x86 process on x64 bit Windows :: or with ARM64 process if it was initiated by x86/ARM32 process on ARM64 Windows
if exist %SystemRoot%\Sysnative\cmd.exe ( set "_cmdf=%~f0" setlocal EnableDelayedExpansion start %SystemRoot%\Sysnative\cmd.exe /c ""!_cmdf!" %*" exit /b )
:: Re-launch the script with ARM32 process if it was initiated by x64 process on ARM64 Windows
if exist %SystemRoot%\Windows\SyChpe32\kernel32.dll if exist %SystemRoot%\SysArm32\cmd.exe if %PROCESSOR_ARCHITECTURE%==AMD64 ( set "_cmdf=%~f0" setlocal EnableDelayedExpansion start %SystemRoot%\SysArm32\cmd.exe /c ""!_cmdf!" %*" exit /b )
:: Set Path variable, it helps if it is misconfigured in the system
set "SysPath=%SystemRoot%\System32" set "Path=%SysPath%;%SystemRoot%;%SysPath%\Wbem;%SysPath%\WindowsPowerShell\v1.0\"
set _args= set _elev= set reset= set Silent= set activate=
set _args=%* if defined _args set _args=%_args:"=% if defined _args ( for %%A in (%_args%) do ( if /i "%%A"=="-el" set _elev=1 if /i "%%A"=="/res" set Unattended=1&set activate=&set reset=1 if /i "%%A"=="/act" set Unattended=1&set activate=1&set reset= if /i "%%A"=="/s" set Unattended=1&set Silent=1 ) )
set "nul=>nul 2>&1" set "_psc=%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" set winbuild=1 for /f "tokens=6 delims=[]. " %%G in ('ver') do set winbuild=%%G call :_colorprep set "nceline=echo: &echo ==== ERROR ==== &echo:" set "line=________________________________________________________________________________________" set "_buf={$W=$Host.UI.RawUI.WindowSize;$B=$Host.UI.RawUI.BufferSize;$W.Height=31;$B.Height=300;$Host.UI.RawUI.WindowSize=$W;$Host.UI.RawUI.BufferSize=$B;}"
if defined Silent if not defined activate if not defined reset exit /b if defined Silent call :begin %nul% & exit /b
if not exist "%_psc%" ( %nceline% echo Powershell is not installed in the system. echo Aborting... goto done2 )
if %winbuild% LSS 7600 ( %nceline% echo Unsupported OS version Detected. echo Project is supported only for Windows 7/8/8.1/10/11 and their Server equivalent. goto done2 )
:: Elevate script as admin and pass arguments and preventing loop :: Thanks to @abbodi1406 for the powershell method and solving special characters issue in file path name.
%nul% reg query HKU\S-1-5-19 || ( if not defined _elev %nul% %_psc% "start cmd.exe -arg '/c \"!_PSarg:'=''!\"' -verb runas" && exit /b %nceline% echo This script require administrator privileges. echo To do so, right click on this script and select 'Run as administrator'. goto done2 )
:: Below code also works for ARM64 Windows 10 (including x64 bit emulation)
reg query "HKLM\Hardware\Description\System\CentralProcessor\0" /v "Identifier" | find /i "x86" 1>nul && set arch=x86|| set arch=x64
if not exist "!IDMan!" ( if %arch%==x64 set "IDMan=%ProgramFiles(x86)%\Internet Download Manager\IDMan.exe" if %arch%==x86 set "IDMan=%ProgramFiles%\Internet Download Manager\IDMan.exe" )
if "%arch%"=="x86" ( set "CLSID=HKCU\Software\Classes\CLSID" set "HKLM=HKLM\Software\Internet Download Manager" set "_tok=5" ) else ( set "CLSID=HKCU\Software\Classes\Wow6432Node\CLSID" set "HKLM=HKLM\SOFTWARE\Wow6432Node\Internet Download Manager" set "_tok=6" )
set _temp=%SystemRoot%\Temp set regdata=%SystemRoot%\Temp\regdata.txt set "idmcheck=tasklist /fi "imagename eq idman.exe" | findstr /i "idman.exe" >nul"
if defined Unattended ( if defined reset goto _reset if defined activate goto _activate )
:MainMenu
cls title IDM 激活 mode 65, 25
:: Check firewall status
set /a _ena=0 set /a _dis=0 for %%# in (DomainProfile PublicProfile StandardProfile) do ( for /f "skip=2 tokens=2*" %%a in ('reg query HKLM\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\%%# /v EnableFirewall 2^>nul') do ( if /i %%b equ 0x1 (set /a _ena+=1) else (set /a _dis+=1) ) )
if %_ena%==3 ( set _status=Enabled set _col=%_Green% )
if %_dis%==3 ( set _status=Disabled set _col=%_Red% )
if not %_ena%==3 if not %_dis%==3 ( set _status=Status_Unclear set _col=%_Yellow% )
if %_erl%==5 exit /b if %_erl%==4 call :readme&goto MainMenu if %_erl%==3 call :_tog_Firewall&goto MainMenu if %_erl%==2 goto _reset if %_erl%==1 goto _activate goto :MainMenu
set "reg=HKCU\SOFTWARE\DownloadManager /v FName /t REG_SZ /d "%name%"" & call :_rcont set "reg=HKCU\SOFTWARE\DownloadManager /v LName /t REG_SZ /d """ & call :_rcont set "reg=HKCU\SOFTWARE\DownloadManager /v Email /t REG_SZ /d "[email protected]"" & call :_rcont set "reg=HKCU\SOFTWARE\DownloadManager /v Serial /t REG_SZ /d "FOX6H-3KWH4-7TSIN-Q4US7"" & call :_rcont
echo: echo 正在触发一些下载以创建某些注册表项,请稍候...
set "file=%_temp%\temp.png" set _fileexist= set _derror=
%idmcheck% && taskkill /f /im idman.exe
set link=https://www.internetdownloadmanager.com/images/idm_box_min.png call :download set link=https://www.internetdownloadmanager.com/register/IDMlib/images/idman_logos.png call :download
:: it may take some time to reflect registry keys. timeout /t 3 >nul
set foundkeys= call :action if [%foundkeys%] GEQ [7] goto _skip
set link=https://www.internetdownloadmanager.com/pictures/idm_about.png call :download set link=https://www.internetdownloadmanager.com/languages/indian.png call :download
timeout /t 3 >nul
set foundkeys= call :action if not [%foundkeys%] GEQ [7] set _derror=1
:_skip
echo: if not defined _derror ( echo 已成功创建所需的注册表项 ) else ( if not defined _fileexist call :_color %Red% "Unable to download files with IDM." call :_color %Red% "Failed to create required registry keys." call :_color %Magenta% "Try again - disable Windows firewall with script options - check Read Me." )
echo: %idmcheck% && taskkill /f /im idman.exe if exist "%file%" del /f /q "%file%" exit /b
:download
set /a attempt=0 if exist "%file%" del /f /q "%file%" start "" /B "!IDMan!" /n /d "%link%" /p "%_temp%" /f temp.png
:check_file
timeout /t 1 >nul set /a attempt+=1 if exist "%file%" set _fileexist=1&exit /b if %attempt% GEQ 20 exit /b goto :Check_file
for /f %%a in (%regdata%) do ( for /f "tokens=%_tok% delims=\" %%# in ("%%a") do ( echo %%#|findstr /r "{.*-.*-.*-.*-.*}" >nul && (set "reg=%%a" & call :scan_key) ) )
:: Colored text with pure batch method :: Thanks to @dbenham and @jeb :: https://stackoverflow.com/a/10407642
:: Powershell is not used here because its slow
:batcol
pushd %_coltemp% if not exist "'" (<nul >"'" set /p "=.") setlocal set "s=%~2" set "t=%~4" call :_batcol %1 s %3 t del /f /q "'" del /f /q "`.txt" popd exit /b
:_batcol
setlocal EnableDelayedExpansion set "s=!%~2!" set "t=!%~4!" for /f delims^=^ eol^= %%i in ("!s!") do ( if "!" equ "" setlocal DisableDelayedExpansion >`.txt (echo %%i\..\') findstr /a:%~1 /f:`.txt "." <nul set /p "=%_BS%%_BS%%_BS%%_BS%%_BS%%_BS%%_BS%" ) if "%~4"=="" echo(&exit /b setlocal EnableDelayedExpansion for /f delims^=^ eol^= %%i in ("!t!") do ( if "!" equ "" setlocal DisableDelayedExpansion >`.txt (echo %%i\..\') findstr /a:%~3 /f:`.txt "." <nul set /p "=%_BS%%_BS%%_BS%%_BS%%_BS%%_BS%%_BS%" ) echo( exit /b
::=======================================
:_colorprep
if %winbuild% GEQ 10586 ( for /F %%a in ('echo prompt $E ^| cmd') do set "esc=%%a"
set "Red="41;97m"" set "Gray="100;97m"" set "Black="30m"" set "Green="42;97m"" set "Blue="44;97m"" set "Yellow="43;97m"" set "Magenta="45;97m""
set "_Red="40;91m"" set "_Green="40;92m"" set "_Blue="40;94m"" set "_White="40;37m"" set "_Yellow="40;93m""
exit /b )
if not defined _BS for /f %%A in ('"prompt $H&for %%B in (1) do rem"') do set "_BS=%%A %%A" set "_coltemp=%SystemRoot%\Temp"
set "Red="CF"" set "Gray="8F"" set "Black="00"" set "Green="2F"" set "Blue="1F"" set "Yellow="6F"" set "Magenta="5F""
set "_Red="0C"" set "_Green="0A"" set "_Blue="09"" set "_White="07"" set "_Yellow="0E""
- To add a custom name in IDM license info, edit the line number 5 in the script file.
- For activation in unattended mode, run the script with /act parameter. - For reset in unattended mode, run the script with /res parameter. - To enable silent mode with above two methods, run the script with /s parameter.
- If any other activator was used to activate IDM previously then make sure to properly uninstall it with that same activator (if there is an option), this is especially important if any registry / firewall block method was used.
- Uninstall the IDM from control panel.
- Make sure the latest original IDM setup is used for the installation, you can download it from https://www.internetdownloadmanager.com/download.html
- Now install the IDM and use the activate option in this script and if failed then,
- Disable windows firewall with the script option, this help in case of leftover entries of previously used activator (some file patch method also creates firewall entries).
- Some security programs may block this script, this is false-positive, as long as you downloaded the file from original post (mentioned below in this page), temporary suspend Antivirus realtime protection, or exclude the downloaded file/extracted folder from scanning.
- If you are still facing any issues, please contact me (mentioned below in this page).
@Dukun Cabul - Original researcher of this IDM trial reset and activation logic, made an Autoit tool for these methods, IDM-AIO_2020_Final nsaneforums.com/topic/371047--/?do=findComment&comment=1632062
@WindowsAddict (Me) - Ported the above Autoit tool to batch script
@AveYo aka @BAU - Snippet to set registry ownership and permission recursively pastebin.com/XTPt0JSC
@abbodi1406 - Awesome batch script tricks and help
@dbenham - Set buffer height independently of window height stackoverflow.com/a/13351373