Windows IT Pro is the leading independent community for IT professionals deploying Microsoft Windows server and client applications and technologies.
  
  
  Advanced Search 


September 08, 2005

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

RSS
Subscribe to Windows IT Pro | See More Tips Articles Here | Reprints | Or get the Monthly Online Pass—only $5.95 a month!


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;Ftype;Action;CommandString

Where:

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
setlocal ENABLEDELAYEDEXPANSION
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
endlocal
goto :EOF
:quiet
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
:quiet1
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%
   )
 )
)



End of Article



Reader Comments

You must be a registered user or online subscriber to comment on this article. Please log on before posting a comment. Are you a new visitor? Register now




Top Viewed ArticlesView all articles
Battery Life Issues Almost Certainly Not Windows 7's Fault

While Microsoft is still investigating a notebook battery life issue that was supposedly caused by Windows 7, some interesting trends have emerged. ...

Confirmed: Battery Life Issues Not Windows 7's Fault

Microsoft on Monday issued a lengthy statement about the recent Windows 7 battery controversy, echoing my assessment from earlier in the day, but backing it up with hard, cold evidence. Put simply, Windows 7 is not responsible for any battery life issues ...

Getting your iPhone to Sync with Exchange 2003

Follow these steps to use an iPhone with Exchange. ...


Related Events 7 Ways To Get More From Your SharePoint Deployment Now

Check out our list of Free Email Newsletters!

Related Resources Introducing Left-Brain.com, the online IT bookstore
Looking for books, CDs, toolkits, eBooks? Prime your mind at Left-Brain.com

Discover Windows IT Pro eLearning Series!
Clear & detailed technical information and helpful how-to's, all in our trademark no-nonsense format


Windows IT Pro Home Register FAQ for Windows WinInfo News
Europe Edition About Us Contact Us/Customer Service Media Kit Affiliates / Licensing  
SQL Server Magazine Office & SharePoint Pro DevProConnections IT Job Hound
Left-Brain.com Technology Resource Directory asp.netPRO ITTV Windows SuperSite 
 
 Windows IT Pro is a Division of Penton Media Inc.
 © 2010 Penton Media, Inc. Terms of Use | Privacy Statement