Skip navigation

JSI Tip 6546. How do I disable a users ability to use the Tools / Folder Options / File Types dialog to change file associations that you specify?


In My Computer and Windows Explorer, the Tools / Folder Options / File Types dialog provides a graphical method of changing file associations. In tip 3674, I described how to prevent users from changing any file association using the GUI.

To prevent a user from changing an association, run:

EditFlags .ext, where .ext is the file extension.

EditFlags.bat contains:

@echo off
setlocal
if \{%1\}

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

"" goto syntax regedit /a %temp%\oldEF.reg "HKEY_CLASSES_ROOT\%ftype%" @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 "Y" @echo "EditFlags"=->>%temp%\NewEF.reg goto hide%ef8% :hide0 set ef8=1 goto out :hide1 goto out :hide2 set ef8=3 goto out :hide3 goto out :hide4 set ef8=5 goto out :hide5 goto out :hide6 set ef8=7 goto out :hide7 goto out :hide8 set ef8=9 goto out :hide9 goto out :hideA set ef8=B goto out :hideB goto out :hideC set ef8=D goto out :hideD goto out :hideE set ef8=F goto out :hideF :out @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 ef1=%string:~6,1% set ef2=%string:~7,1% set ef3=%string:~8,1% set ef4=%string:~9,1% set ef5=%string:~10,1% set ef6=%string:~11,1% set ef7=%string:~12,1% set ef8=%string:~13,1% 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