Advertisement
adamchilcott

defaultIEExplore.cmd

Jan 23rd, 2018
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 2.89 KB | None | 0 0
  1. @echo off
  2. setlocal enabledelayedexpansion
  3.  
  4. REM -- check XHTML support (IE 9+)
  5. set xhtml=0
  6. for /f %%G in ('"reg query "HKCR\IE.AssocFile.XHT" /ve 2>&1 | findstr /c:".XHT" "') do set xhtml=1
  7.  
  8. REM -- reset file extensions
  9. set exts=HTM,HTML
  10. if %xhtml% == 1 (set exts=%exts%,XHT,XHTML)
  11.  
  12. for %%G in (%exts%) do (
  13. set ext=%%G
  14. set ext=!ext:~0,3!
  15. reg add "HKCU\Software\Classes\.%%G" /ve /t REG_SZ /d "IE.AssocFile.!ext!" /f >nul
  16. )
  17.  
  18. set exts=%exts%,MHT,MHTML,URL
  19. set acl=%temp%\acl_%random%%random%.txt
  20.  
  21. for %%G in (%exts%) do (
  22. set key=HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.%%G\UserChoice
  23. echo !key! [1 7 17]>"%acl%"
  24. regini "%acl%" >nul
  25. set ext=%%G
  26. set ext=!ext:~0,3!
  27. reg add "!key!" /v "Progid" /t REG_SZ /d "IE.AssocFile.!ext!" /f >nul
  28. )
  29. del "%acl%" 2>nul
  30.  
  31. REM -- reset MIME associations
  32. for %%G in (message/rfc822,text/html) do (
  33. set key=HKCU\Software\Microsoft\Windows\Shell\Associations\MIMEAssociations\%%G\UserChoice
  34. reg add "!key!" /v "Progid" /t REG_SZ /d "IE.%%G" /f >nul
  35. )
  36.  
  37. REM -- reset URL protocols
  38. for %%A in (FTP,HTTP,HTTPS) do (
  39. set key=HKCU\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\%%A\UserChoice
  40. reg add "!key!" /v "Progid" /t REG_SZ /d "IE.%%A" /f >nul
  41. for %%B in (DefaultIcon,shell) do (
  42. set key=HKCU\Software\Classes\%%A
  43. reg delete "!key!\%%B" /f >nul 2>&1
  44. reg copy "HKCR\IE.%%A\%%B" "!key!\%%B" /s /f >nul
  45. reg add "!key!" /v "EditFlags" /t REG_DWORD /d 2 /f >nul
  46. reg add "!key!" /v "URL Protocol" /t REG_SZ /d "" /f >nul
  47. ))
  48.  
  49. REM -- reset the start menu Internet link (Vista and earlier)
  50. reg add "HKCU\Software\Clients\StartMenuInternet" /ve /t REG_SZ /d "IEXPLORE.EXE" /f
  51.  
  52. REM -- reset cached icons
  53. if %xhtml% == 1 (
  54. ie4uinit -cleariconcache
  55. ) else (
  56. taskkill /im explorer.exe /f >nul
  57. start explorer
  58. )
  59.  
  60. pause
  61. exit /b
  62.  
  63. REM #############
  64. REM # START NOTES
  65. REM #############
  66.  
  67. REM ## Reference:
  68. REM ## <https://superuser.com/questions/300770/set-internet-explorer-as-the-default-browser-from-the-command-line/300801>
  69.  
  70. REM ## The following batch script simulates clicking Set this programs as default from the Default Programs control panel applet.
  71. REM ## Tested with Vista/7 and IE 7/IE 11.
  72.  
  73. REM ## Any web browser application can register to appear as an Internet client on the Start menu.
  74. REM ## This visibility, coupled with proper registration for an application's file and protocol types, gives an application default browser status.
  75. REM ## The default web browser is used for launching arbitrary URLs from anywhere in the system.
  76. REM ## Note Existing [start menu link] registrations are ignored in Windows 7 and later. This registration is deprecated as of Windows 7.
  77.  
  78. REM ## The hierarchical registry structure for file and protocol associations gives precedence to per-user defaults over machine-level defaults.
  79.  
  80. REM ###########
  81. REM # END NOTES
  82. REM ###########
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement