JSI Tip 9715. How can I generate a file association report?

Using REG.EXE, built into Windows XP, Windows Server 2003, and later, or installed on Windows 2000 from the Support Tools folder of of the Windows 2000 CD-ROM, I have scripted AssocList.bat to generate a semi-colon delimited file containing:



Assoc         is the file extension, like .txt. Two special extensions are Directory and Folder.

Ftype         is the registry sub-key in the HKCR key that houses the Action definition, like txtfile.

Action        is the command that appears on the context menu, like Open, Print, and Edit.

CommandString defines the program and parameter(s) required to perform the Action, like %SystemRoot%\system32\NOTEPAD.EXE %1.
The syntax for using AssocList.bat is:

AssocList \[ComputerName\]

Where ComputerName is optional, defaulting to the local computer.

The output is written to AssocList_<ComputerName>.txt in the current directory.

AssocList.bat contains:

@echo off
set comp=%1
if "%comp%" EQU "" set comp=%ComputerName%
set comp=%comp:"=%
set comp=%comp:\=%
set file=AssocList_%comp%.txt
if exist %file% del /q %file%
set comp=\\%comp%
set assoc=Directory
set ftype=Directory
set ftk="%comp%\HKLM\Software\Classes\Directory\Shell"
call :quiet1>nul 2>&1
set assoc=Folder
set ftype=Folder
set ftk="%comp%\HKLM\Software\Classes\Folder\Shell"
call :quiet1>nul 2>&1
call :quiet>nul 2>&1
goto :EOF
for /f "Tokens=4 Delims=\" %%a in ('reg query "%comp%\HKLM\SOFTWARE\Classes"^|find "\."') do (
 set assoc=%%a
 set key=HKLM\SOFTWARE\Classes\%%a
 for /f "Tokens=3*" %%b in ('reg query "%comp%\!key!" /Ve^|find "REG_"') do (
  set ftype=%%c
 set ftk="%comp%\HKLM\Software\Classes\!ftype!\Shell"
 for /f "Tokens=*" %%d in ('reg query !ftk!^|find /i "Shell"') do (
  for /f "Tokens=5* Delims=\" %%x in ('@echo %%d') do (
   set command=%%y
   set ftl="%comp%\HKLM\Software\Classes\!ftype!\Shell\%%y\command"
   for /f "Tokens=3*" %%i in ('reg query !ftl! /Ve^|find "REG_"') do (
    set prog=%%j
    @echo !assoc!;!ftype!;!command!;!prog!>>%file%
goto :EOF
for /f "Tokens=*" %%d in ('reg query %ftk%^|find /i "Shell"') do (
 for /f "Tokens=5* Delims=\" %%x in ('@echo %%d') do (
   set command=%%y
   set ftl="%comp%\HKLM\Software\Classes\%ftype%\Shell\%%y\command"
   for /f "Tokens=3*" %%i in ('reg query !ftl! /Ve^|find "REG_"') do (
    set prog=%%j
    @echo %assoc%;%ftype%;!command!;!prog!>>%file%

Hide 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.