Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for regdll.bat

(view source code of regdll.bat as plain text)

  1. @ECHO OFF
  2. :: Check Windows version
  3. IF "%OS%"=="Windows_NT" (SETLOCAL) ELSE (GOTO Syntax)
  4. VER | FIND "Windows NT" >NUL && GOTO Syntax
  5.  
  6. :: Check command line argument - none required
  7. IF NOT "%~1"=="" GOTO Syntax
  8.  
  9. :: Warning message and confirmation
  10. CLS
  11. ECHO.
  12. ECHO Warning: You are about to make changes to the Windows registry.
  13. ECHO          Changing the registry is not without risk!
  14. ECHO          Continuing could lead to loss of data, and even a "dead" PC.
  15. ECHO          The author cannot be held responsible for any damage, neither
  16. ECHO          direct nor consequential, caused by using this script.
  17. ECHO          Use this script entirely at your own risk.
  18. ECHO.
  19. ECHO          Type YES and press Enter if you understand the risk and
  20. ECHO          accept full responsibility...
  21. SET /P Answer=
  22. IF /I NOT "%Answer%"=="YES" (
  23. 	ECHO Aborted by user...
  24. 	GOTO End
  25. )
  26.  
  27. :: Create temporary .REG file
  28. SET RegFile="%Temp:"=%.\RegDLL.dat"
  29. >  %RegFile% ECHO REGEDIT4
  30. >> %RegFile% ECHO.
  31. >> %RegFile% ECHO [HKEY_CLASSES_ROOT\dllfile\shell]
  32. >> %RegFile% ECHO.
  33. >> %RegFile% ECHO [HKEY_CLASSES_ROOT\dllfile\shell\Register DLL]
  34. >> %RegFile% ECHO.
  35. >> %RegFile% ECHO [HKEY_CLASSES_ROOT\dllfile\shell\Register DLL\command]
  36. >> %RegFile% ECHO @="\"regsvr32.exe\" %%1"
  37. >> %RegFile% ECHO.
  38. >> %RegFile% ECHO [HKEY_CLASSES_ROOT\dllfile\shell\Unregister DLL]
  39. >> %RegFile% ECHO.
  40. >> %RegFile% ECHO [HKEY_CLASSES_ROOT\dllfile\shell\Unregister DLL\command]
  41. >> %RegFile% ECHO.@="\"regsvr32.exe\" /u %%1"
  42. >> %RegFile% ECHO.
  43.  
  44. :: Export current registry settings to undo file
  45. ECHO.
  46. ECHO Creating Undo and Restore files...
  47. START /WAIT REGEDIT /E RegDLL_Restore.reg "HKEY_CLASSES_ROOT\dllfile"
  48. >  RegDLL_Remove.reg ECHO REGEDIT4
  49. >> RegDLL_Remove.reg ECHO.
  50. >> RegDLL_Remove.reg ECHO [-HKEY_CLASSES_ROOT\dllfile\shell]
  51. >> RegDLL_Remove.reg ECHO.
  52.  
  53. :: Import registry settings from temporary .REG file
  54. ECHO.
  55. ECHO Modifying registry settings for DLL files...
  56. START /WAIT REGEDIT /S %RegFile%
  57.  
  58. :: Remove temporary .REG file
  59. DEL %RegFile%
  60.  
  61. :: Exit message
  62. ECHO.
  63. ECHO You can now register and unregister DLL files in Explorer.
  64. ECHO Right-clicking a DLL file will show 2 new menu entries:
  65. ECHO     Register DLL
  66. ECHO     Unregister DLL
  67. ECHO.
  68. ECHO To uninstall this option, doubleclick ^(and confirm^)
  69. ECHO RegDLL_Remove.reg first, followed by RegDLL_Restore.reg.
  70. ECHO Both are stored in the current directory.
  71. GOTO End
  72.  
  73. :Syntax
  74. ECHO.
  75. ECHO RegDLL.bat,  Version 1.01 for Windows 2000 / XP
  76. ECHO Register and unregister DLL files in Explorer
  77. ECHO.
  78. ECHO Based on an article on The Code Project's website
  79. ECHO http://www.codeproject.com/w2k/regdllxp.asp
  80. ECHO.
  81. ECHO Usage:  REGDLL
  82. ECHO.
  83. ECHO After running this script, right-clicking a DLL file will show 2
  84. ECHO new menu entries:   Register DLL
  85. ECHO                     Unregister DLL
  86. ECHO.
  87. ECHO To uninstall this option, doubleclick (and confirm)
  88. ECHO RegDLL_Remove.reg first, followed by RegDLL_Restore.reg.
  89. ECHO Both are created in the current directory when running this script.
  90. ECHO.
  91. ECHO Note:   Unless you are a power user or administrator, restrictions
  92. ECHO         on your computer may prevent you from modifying the registry.
  93. ECHO.
  94. ECHO Written by Rob van der Woude
  95. ECHO http://www.robvanderwoude.com
  96.  
  97. :End
  98. IF "%OS%"=="Windows_NT" ENDLOCAL
  99.  

page last modified: 2024-04-16; loaded in 0.0049 seconds