Configuring File Associations for Users
For the OS shell to know which application to launch when you double-click a data file, two items must be defined: the file-extension key and the associated program class. Files are classified based on their extension (e.g., .doc, .xls), so files with the same extension are considered to be the same type or class. You can instruct the shell to open files of a given class with a specific application—this is known as association.
File-extension keys and program classes are stored in the registry in the HKEY_CLASSES_ROOT subtree. This subtree contains values from the HKEY_LOCAL_MACHINE\SOFTWARE\Classes subkey (which contains global settings) and the HKEY_CURRENT_USER\Software\Classes subkey (which contains individual user settings). If a value exists in both Classes subkeys, the user setting wins over the global setting.
You might be familiar with the GUI methods for associating a file type with a program. If you attempt to open a data file for which no association exists, you're presented with the Open With dialog box, which gives you the option of making your selected application the default association. You can also create file associations in Windows Explorer by selecting Folder Options on the Tools menu, then clicking the File Types tab. These methods are fine if you know what you're doing and you need to create the file associations on only a couple of systems. However, if you need to create file associations for a large group of users, you should familiarize yourself with two XP command-line tools: Assoc, which lets you create a file-extension key, and Ftype, which lets you create a program class.
Listing 1 demonstrates how to use these commands. The first line creates a file-extension key called .elog that has a value of CompanyName Text. In simple terms, Assoc is telling the OS shell that when it encounters a file with the .elog extension, it should refer to the CompanyName Text program class for instructions on how to open that file. The next two lines accomplish the same task for two other file extensions (i.e., .ref and .glo). Note that when you specify the program class name in Assoc and Ftype, you just need to use the friendly name. If necessary, you can elaborate on the name to avoid confusion by adding a period (.) followed by the qualifier (e.g., CompanyName Text.Logfile).
The last line in Listing 1 uses the Ftype command to create the CompanyName Text program class. The Ftype command accomplishes this task by creating the CompanyName Text subkey in the HKEY_LOCAL_MACHINE\SOFTWARE\Classes subkey. The value of the CompanyName Text subkey is the pathname of the executable file that will be used to open associated data files (in this case, C:\Program Files\Microsoft Office\Office\Winword.exe). The "%%1" parameter allows the data file to be passed to the executable as an argument; without that parameter, the application would open, but the data file that launched it wouldn't be loaded.
If you were to double-click a file with an .elog, .ref, or .glo extension after you ran the commands in Listing 1, Microsoft Word would open that file. You can add the Assoc and Ftype commands to a logon script or distribute the commands through other tools to provide consistent application usage among your users.
Note that the values you set using these commands will overwrite previous associations. So, if your users have made their own associations, you can still enforce your organization's standards. If you need to remove an association, it's easy to do so. For example, if you want to delete the .elog association, you'd run the command
Assoc .elog=
An Important Control
Although offering a Web-accessible repository of file extensions and possible associated applications is a noble concept, there are a few factors that make the file association Web service an unsatisfactory solution for end users and IT organizations. By disabling access to the file association Web service and configuring file associations for your users, you can head off frustration and wasted time for users and support staff alike.
Project Snapshot: How to
PROBLEM: If left enabled, XP's file association Web service can lead to frustrated users and numerous IT service calls. WHAT YOU NEED: XP's built-in Assoc and Ftype command-line tools DIFFICULTY: 2 out of 5 PROJECT STEPS:
Block the file association Web service by adding an entry in the registry.
Configure file associations for files commonly used within your environment.
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
An often irreverent look at some of the week's other news, including some post-PDC some soul searching, a Google Chrome OS announcement and a Microsoft response, Windows 7 off to a supposedly strong start, the Jonas Brothers and Xbox 360, and so much more ...
Picking a favorite product from an impressive crowd of competitive offerings is never an easy task, and such was the case with our Editors' Best and Community Choice awards this year. ...
Free CDs Offer Fundamental Content for IT Pros Are you up to speed on the latest technologies and solutions? Don't miss out on your chance to get up to speed quickly on fundamental, in-depth information on some of the hottest topics in our library of content.
Let Your Users Reset Their Own Passwords: Free Download Try a 30 day free trial of Desktop Authority Password Self-Service – it provides an easy-to-use, robust system for allowing users to reset their own forgotten passwords or locked accounts.
Get Windows IT Pro & Mark Minasi’s Favorite Power Tools Guide Order Windows IT Pro now and get "More of Mark Minasi's Favorite Power Tools"--a in-depth guide to the most useful Windows commands --FREE with your paid order! Subscribe today, and save 58% off the cover price!
Deep Dive into VMware vSphere, eLearning Series Join John Savill to explore the major functionality capabilities of the vSphere virtualization platform, including identification of the changes from ESX 3.5.