Advertisement
Guest User

idm reset

a guest
May 23rd, 2020
5,690
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.47 KB | None | 0 0
  1. @setlocal DisableDelayedExpansion
  2. @echo off
  3.  
  4.  
  5.  
  6.  
  7.  
  8. ::=========================================================================================================
  9. : Credits:
  10. ::=========================================================================================================
  11.  
  12. :: IDM trial reset logic is taken from @Dukun Cabul's autoit tool IDM-AIO 2020 Final.exe
  13. :: https://www.nsaneforums.com/topic/366535--/?do=findComment&comment=1562675
  14.  
  15. :: @WindowsAddict - IDM Trial Script
  16.  
  17. ::=========================================================================================================
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25. ::========================================================================================================================================
  26.  
  27. title IDM Trial Script 0.1
  28. set _elev=
  29. if /i "%~1"=="-el" set _elev=1
  30. for /f "tokens=6 delims=[]. " %%G in ('ver') do set winbuild=%%G
  31. set "_psc=powershell -nop -ep bypass -c"
  32. set "nul=1>nul 2>nul"
  33. set "ELine=echo: & %_psc% write-host -back Black -fore Red ==== ERROR ==== &echo:"
  34. set line=_____________________________________________________________________________________________________
  35.  
  36. ::========================================================================================================================================
  37.  
  38. for %%i in (powershell.exe) do if "%%~$path:i"=="" (
  39. echo: &echo ==== ERROR ==== &echo:
  40. echo Powershell is not installed in the system.
  41. echo Aborting...
  42. goto Done
  43. )
  44.  
  45. ::========================================================================================================================================
  46.  
  47. if %winbuild% LSS 7600 (
  48. %ELine%
  49. echo Unsupported OS version Detected.
  50. echo Project is supported only for Windows 7/8/8.1/10 and their Server equivalent.
  51. goto Done
  52. )
  53.  
  54. ::========================================================================================================================================
  55.  
  56. :: Elevate script as admin and pass arguments and preventing loop
  57. :: Thanks to @hearywarlot [ https://forums.mydigitallife.net/threads/.74332/ ] for the VBS method.
  58. :: Thanks to @abbodi1406 for the powershell method and solving special characters issue in file path name.
  59.  
  60. :: VBS method as a first attempt is used because the powershell elevation is slow to load on average machines, and powershell elevation
  61. :: as a fallback is used because WSH can be blocked on system.
  62.  
  63. %nul% reg query HKU\S-1-5-19 && (
  64. goto :_Passed
  65. ) || (
  66. if defined _elev goto :_E_Admin
  67. )
  68.  
  69.  
  70. set "batf_=%~f0"
  71. set "batp_=%batf_:'=''%"
  72.  
  73. set "_vbsf=%temp%\admin.vbs"
  74. set _PSarg="""%~f0""" -el
  75.  
  76. setlocal EnableDelayedExpansion
  77. (
  78. echo Set strArg=WScript.Arguments.Named
  79. echo Set strRdlproc = CreateObject^("WScript.Shell"^).Exec^("rundll32 kernel32,Sleep"^)
  80. echo With GetObject^("winmgmts:\\.\root\CIMV2:Win32_Process.Handle='" ^& strRdlproc.ProcessId ^& "'"^)
  81. echo With GetObject^("winmgmts:\\.\root\CIMV2:Win32_Process.Handle='" ^& .ParentProcessId ^& "'"^)
  82. echo If InStr ^(.CommandLine, WScript.ScriptName^) ^<^> 0 Then
  83. echo strLine = Mid^(.CommandLine, InStr^(.CommandLine , "/File:"^) + Len^(strArg^("File"^)^) + 8^)
  84. echo End If
  85. echo End With
  86. echo .Terminate
  87. echo End With
  88. echo CreateObject^("Shell.Application"^).ShellExecute "cmd.exe", "/c " ^& chr^(34^) ^& chr^(34^) ^& strArg^("File"^) ^& chr^(34^) ^& strLine ^& chr^(34^), "", "runas", 1
  89. )>"!_vbsf!"
  90.  
  91. (%nul% cscript //NoLogo "!_vbsf!" /File:"!batf_!" -el) && (
  92. del /f /q "!_vbsf!"
  93. exit /b
  94. ) || (
  95. del /f /q "!_vbsf!"
  96. %nul% %_psc% "start cmd.exe -arg '/c \"!_PSarg:'=''!\"' -verb runas" && (
  97. exit /b
  98. ) || (
  99. goto :_E_Admin
  100. )
  101. )
  102. exit /b
  103.  
  104. :_E_Admin
  105. %ELine%
  106. echo This script require administrator privileges.
  107. echo To do so, right click on this script and select 'Run as administrator'.
  108. goto Done
  109.  
  110. :_Passed
  111.  
  112. ::========================================================================================================================================
  113.  
  114. :: Fix for the special characters limitation in path name
  115. :: Written by @abbodi1406
  116.  
  117. set "_work=%~dp0"
  118. if "%_work:~-1%"=="\" set "_work=%_work:~0,-1%"
  119.  
  120. set "_batf=%~f0"
  121. set "_batp=%_batf:'=''%"
  122.  
  123. setlocal EnableDelayedExpansion
  124.  
  125. ::========================================================================================================================================
  126.  
  127. cls
  128. mode con: cols=98 lines=30
  129. echo:
  130. echo:
  131. echo:
  132. echo:
  133. echo _______________________________________________________________
  134. echo ^| ^|
  135. echo ^| ^|
  136. echo ^| [1] Reset IDM Trial ^|
  137. echo ^| ___________________________________________________ ^|
  138. echo ^| ^|
  139. echo ^| [2] Exit ^|
  140. echo ^| ^|
  141. echo ^|_______________________________________________________________^|
  142. echo:
  143. choice /C:12 /N /M "> Enter Your Choice [1,2] : "
  144.  
  145. if errorlevel 2 exit
  146. if errorlevel 1 goto Reset
  147.  
  148. ::========================================================================================================================================
  149.  
  150. :Reset
  151.  
  152. cls
  153.  
  154. :: Set buffer height independently of window height
  155. :: https://stackoverflow.com/a/13351373
  156. :: Written by @dbenham (stackoverflow)
  157.  
  158. mode con: cols=105 lines=30
  159. %nul% %_psc% "&{$H=get-host;$W=$H.ui.rawui;$B=$W.buffersize;$B.height=999;$W.buffersize=$B;}"
  160.  
  161. ::========================================================================================================================================
  162.  
  163. :: Check Windows Architecture
  164.  
  165. reg Query "HKLM\Hardware\Description\System\CentralProcessor\0" | find /i "x86" > nul && set arch=x86|| set arch=x64
  166.  
  167. ::========================================================================================================================================
  168.  
  169. echo:
  170. echo Deleting registry keys...
  171. echo:
  172.  
  173. if "%arch%"=="x86" set "Reg__key=HKCU\Software\Classes\CLSID" &set tokn=5
  174. if "%arch%"=="x64" set "Reg__key=HKCU\Software\Classes\Wow6432Node\CLSID" &set tokn=6
  175.  
  176. for %%# in (
  177. "HKLM\SOFTWARE\Wow6432Node\Internet Download Manager"
  178. "HKLM\Software\Internet Download Manager"
  179. ""HKCU\Software\DownloadManager" "/v" "FName""
  180. ""HKCU\Software\DownloadManager" "/v" "LName""
  181. ""HKCU\Software\DownloadManager" "/v" "Email""
  182. ""HKCU\Software\DownloadManager" "/v" "Serial""
  183. ""HKCU\Software\DownloadManager" "/v" "scansk""
  184. ""HKCU\Software\DownloadManager" "/v" "tvfrdt""
  185. ""HKCU\Software\DownloadManager" "/v" "radxcnt""
  186. ""HKCU\Software\DownloadManager" "/v" "LstCheck""
  187. ""HKCU\Software\DownloadManager" "/v" "ptrk_scdt""
  188. ""HKCU\Software\DownloadManager" "/v" "LastCheckQU""
  189. ) do for /f "tokens=* delims=" %%A in ("%%~#") do (
  190. set "reg="%%~A"" &reg query !reg! 2>nul | find /i "H" 1>nul && call :Delete_2a
  191. )
  192.  
  193. for %%# in (
  194. MData
  195. Model
  196. scansk
  197. Therad
  198. ) do for /f "tokens=* delims=" %%G in ("%%~#") do (
  199. for /f "tokens=%tokn% delims=\" %%a in ('reg query %Reg__key% /s /f %%G /e 2^>nul ^| find /i "CLSID"') do if not [%%a]==[] set "reg=%Reg__key%\%%a" &call :Delete_2
  200. )
  201.  
  202. for /f "tokens=%tokn% delims=\" %%a in ('reg query %Reg__key% /s /f Version /k /e 2^>nul ^| find /i "CLSID"') do if not [%%a]==[] set "reg=%Reg__key%\%%a" &call :Delete_3
  203.  
  204. ::========================================================================================================================================
  205.  
  206. echo:
  207. echo Adding registry key...
  208. echo:
  209.  
  210. if "%arch%"=="x64" (
  211. set "key_HKLM="HKLM\SOFTWARE\WOW6432Node\Internet Download Manager" /v "AdvIntDriverEnabled2""
  212. ) else (
  213. set "key_HKLM="HKLM\Software\Internet Download Manager" /v "AdvIntDriverEnabled2""
  214. )
  215.  
  216. Reg add %key_HKLM% /t REG_DWORD /d "1" /f %nul%
  217.  
  218. reg query %key_HKLM% 2>nul | find /i "H" 1>nul
  219.  
  220. if [%errorlevel%]==[0] (
  221. echo Added - %key_HKLM%
  222. ) else (
  223. powershell write-host 'Failed' -fore '"white"' -back ' "DarkRed"' -NoNewline &echo - %key_HKLM%
  224. )
  225.  
  226. echo:
  227.  
  228. ::========================================================================================================================================
  229.  
  230. :Done
  231.  
  232. echo %line%
  233. echo:
  234. echo:
  235. echo Press any key to exit...
  236. pause >nul
  237. exit /b
  238.  
  239. ::========================================================================================================================================
  240.  
  241. :Delete_3
  242.  
  243. for /f "skip=2 tokens=2*" %%a in ('reg query !reg!\Version /ve 2^>nul') do if 1%%b EQU +1%%b (
  244. call :Delete_2
  245. exit /b
  246. )
  247. exit /b
  248.  
  249. ::========================================================================================================================================
  250.  
  251. :Delete_2
  252.  
  253. set "reg="!reg!""
  254. reg query !reg! 2>nul | find /i "H" 1>nul || exit /b
  255.  
  256. reg query !reg! 2>nul | find /i "LocalServer32" 1>nul && exit /b
  257. reg query !reg! 2>nul | find /i "InprocServer32" 1>nul && exit /b
  258. reg query !reg! 2>nul | find /i "InprocHandler32" 1>nul && exit /b
  259.  
  260. :Delete_2a
  261.  
  262. reg delete !reg! /f %nul%
  263.  
  264. reg query !reg! 2>nul | find /i "H" 1>nul
  265.  
  266. if [%errorlevel%]==[0] (
  267. powershell write-host 'Failed' -fore '"white"' -back ' "DarkRed"' -NoNewline &echo - !reg!
  268. ) else (
  269. echo Deleted - !reg!
  270. )
  271.  
  272. exit /b
  273.  
  274. ::========================================================================================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement