Skip navigation

JSI Tip 8408. How do I convert any REG_BINARY EditFlags data types to REG_DWORD?


In tip 8407, I explained how the EditFlags Value Name controls a users ability to modify a files association.

To convert all REG_BINARY EditFlags data types to REG_DWORD, run EditFlags2DWORD.bat, which contains:

@echo off
setlocal
if exist %temp%\AllEF.reg del /q /f %temp%\AllEF.reg
regedit /a %temp%\AllEF.reg "HKEY_CLASSES_ROOT"
for /f "Tokens=*" %%x in ('type %temp%\AllEF.reg^|find "\."') do (
 set w1=%%x
 call :isext
)
del /q /f %temp%\AllEF.reg
endlocal
goto :EOF
:isext
set w1=%w1:~19%
set w2=%w1:\=%
if "%w1%" NEQ "%w2%" goto :EOF
set w1=%w1:\]=%
call :convert %w1%
goto :EOF
:convert
if \{%1\}

\{\} goto finish set type=%1 if not "%type:~0,1%" EQU "." goto finish if "%type:~2,1%" EQU "=" goto finish if "%type:~3,1%" EQU "=" goto finish if "%type:~4,1%" EQU "=" goto finish if "%type:~5,1%" EQU "=" goto finish if "%type:~6,1%" EQU "=" goto finish for /f "Tokens=*" %%a in ('assoc %type%') do set ftype=%%a if /i "%ftype:~0,4%" EQU "%type%" goto OK :finish goto :EOF :OK call set work=%%ftype:%type%=%% set ftype=%work:~1,99% if "%ftype%"

"" goto finish regedit /a %temp%\oldEF.reg "HKEY_CLASSES_ROOT\%ftype%" if not exist %temp%\oldEF.reg goto :EOF @echo REGEDIT4>%temp%\NewEF.reg @echo.>>%temp%\NewEF.reg @echo \[HKEY_CLASSES_ROOT\%ftype%\]>>%temp%\NewEF.reg set sw=Y set ef=N set ef1=0 set ef2=1 set ef3=0 set ef4=0 set ef5=0 set ef6=0 set ef7=0 set ef8=0 for /f "Skip=3 Tokens=1* Delims==" %%a in ('type %temp%\oldEF.reg') do set vn=%%a&set string=%%b&call :parse if "%ef%" EQU "N" goto :EOF @echo "EditFlags"=->>%temp%\NewEF.reg @echo "EditFlags"=dword:%ef1%%ef2%%ef3%%ef4%%ef5%%ef6%%ef7%%ef8%>>%temp%\NewEF.reg regedit /s %temp%\NewEF.reg del /q %temp%\NewEF.reg del /q %temp%\oldEF.reg goto :EOF :parse if "%sw%" EQU "N" goto :EOF set vn=%vn:"=% if "%vn:~0,1%" EQU "\[" set sw=N&goto :EOF if /i not "%vn%" EQU "EditFlags" goto :EOF set ef=Y if /i "%string:~0,6%" EQU "dword:" goto efdw if /i "%string:~0,4%" EQU "hex:" goto efhx goto :EOF :efdw set ef=N goto :EOF :efhx set ef7=%string:~4,1% set ef8=%string:~5,1% set ef5=%string:~7,1% set ef6=%string:~8,1% set ef3=%string:~10,1% set ef4=%string:~11,1% set ef1=%string:~13,1% set ef2=%string:~14,1%



Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish