1. Creating a New File Type
Windows Vista comes with a long list of
registered file types, but it can’t account for every extension you’ll
face in your computing career. For rare extensions, it’s best just to
use the Open With dialog box. However, if you have an unregistered
extension that you encounter frequently, you should register that
extension by creating a new file type for it.
Tip
Text files, in particular, seem to come with all
kinds of nonstandard (that is, unregistered) extensions. Rather than
constantly setting up file types for these extensions or using the Open
With dialog box, I created a shortcut for Notepad in my %USERPROFILE\SendTo folder. That way, I can open any text file by right-clicking it and then selecting Send To, Notepad.
Our old friend the Open With dialog box provides a
quick-and-dirty method for creating a simple file type for an
unregistered extension:
1. | In Windows Explorer, select the file you want to work with.
|
2. | Click
Open. (For unregistered file types, Windows Vista doesn’t display the
Open With command.) Vista displays a dialog box telling you that it
cannot open the file.
|
3. | Activate the Select a Program from a List of Installed Programs option and then click OK. The Open With dialog box appears.
|
4. | Select the application you want to use to open the file or click Browse to choose the program from a dialog box.
|
5. | Use the Type a Description That You Want to Use for this Kind of File text box to enter a description for the new file type.
|
6. | Make sure that the Always Use the Selected Program to Open This Kind of File check box is activated.
|
7. | Click OK.
|
This method creates a new file type with the following properties:
The number of actions Windows Vista
creates for the file type depends on the application you selected. If
you can use the application to both display and edit the file, Windows
Vista creates Open and Edit actions; if you can use the application only to display the file, Windows Vista creates just the Open action.
The icon associated with the file is the same as the one used by the associated application.
In the Registry, you see the extension in HKEY_CLASSES_ROOT and the associated file type name is ext_auto_file, where ext is the file’s extension.
2. Associating Two or More Extensions with a Single File Type
The problem with creating a new file type is that
you often have to reinvent the wheel. For example, let’s say you want
to set up a new file type that uses the .1st extension. These are usually text files (such as readme.1st)
that provide pre-installation instructions, so you probably want to
associate them with Notepad. However, this means repeating some or all
of the existing Text Document file types. To avoid this, it’s possible
to tell Windows Vista to associate a second extension with an existing
file type. Here are the steps to follow:
1. | Open the Registry Editor.
|
2. | Select the HKEY_CLASSES_ROOT key.
|
3. | Select Edit, New, Key.
|
4. | Type the file extension used with the new file type (such as .1st), and press Enter.
|
5. | In the new file extension key, double-click Default.
|
6. | Type
the name of the existing file type key that you want to associate with
the new file type. For example, if you want the new file type to be
associated with the Text Document (.txt) file type, enter txtfile.
|
7. | Click OK.
|
3. Customizing the New Menu
One of Windows Vista’s handiest features is the
New menu, which enables you to create a new file without working within
an application. In Windows Explorer (or on the desktop), right-click an
empty part of the folder and then select New. In the submenu that
appears, you’ll see items that create new documents of various file
types, including a folder, shortcut, bitmap image, WordPad document,
text document, compressed folder, and possibly many others, depending on
your system configuration and the applications you have installed.
What
mechanism determines whether a file type appears on the New menu? The
Registry, of course. To see how this works, start the Registry Editor
and open the HKEY_CLASSES_ROOT key. As you’ve seen, most of the extension subkeys have only a Default
setting that’s either blank (if the extension isn’t associated with a
registered file type) or a string that points to the extension’s
associated file type.
However, many of these extension keys also have subkeys and a few of them have a subkey named ShellNew, in particular. For example, open the .bmp key and you see that it has a subkey named ShellNew.
This subkey is what determines whether a file type appears on the New
menu. Specifically, if the extension is registered with Windows Vista
and it has a ShellNew subkey, the New menu sprouts a command for the associated file type.
The ShellNew subkey always contains a setting that determines how Windows Vista creates the new file. Four settings are possible:
NullFile | This
setting, the value of which is always set to a null string (“”), tells
Windows Vista to create an empty file of the associated type. Of the
file types that appear on the default New menu, three use the NullFile setting: Text Document (.txt), Bitmap Image (.bmp), and Shortcut (.lnk). |
Directory | This setting tells Windows Vista to create a folder. The New menu’s Briefcase (see the Briefcase\ShellNew key in the Registry) command uses this setting. |
Command | This
setting tells Windows Vista to create the new file by executing a
specific command. This command usually invokes an executable file with a
few parameters. Two of the New menu’s commands use this setting: Contact—The .contact\ShellNew key contains the following value for the Command setting: "%ProgramFiles%\Windows Mail\Wab.exe" /CreateContact "%1"
Journal Document—In the .jnt\jntfile\ShellNew key, you’ll see the following value for the Command setting: "%ProgramFiles%\Windows Journal\Journal.exe" /n 0
|
Data | This
setting contains a value, and when Windows Vista creates the new file,
it copies this value into the file. The New menu’s Rich Text Document
(.rtf) and Compressed (Zipped) Folder (.zip)commands use this setting. |
Adding File Types to the New Menu
To make the New menu even more convenient, you
can add new file types for documents you work with regularly. For any
file type that’s registered with Windows Vista, you follow a simple
three-step process:
1. | Add a ShellNew subkey to the appropriate extension key in HKEY_CLASSES_ROOT.
|
2. | Add one of the four settings discussed in the preceding section (NullFile, Directory, Command, or Data).
|
3. | Type a value for the setting.
|
In most cases, the easiest way to go is to use NullFile to create an empty file.
Deleting File Types from the New Menu
Many Windows Vista applications (such as
Microsoft Office) like to add their file types to the New menu. If you
find that your New menu is getting overcrowded, you can delete some
commands to keep things manageable. To do this, you need to find the
appropriate extension in the Registry and delete its ShellNew subkey.
Caution
Instead of permanently deleting a ShellNew subkey, you can tread a more cautious path by simply renaming the key (to, for example, ShellNewOld).
This still prevents Windows Vista from adding the item to the New menu,
but it also means that you can restore the item just by restoring the
original key name. Note, however, that some third-party Registry cleanup
programs flag such renamed keys for deletion or restoration. The better
programs—such as Registry Mechanic (www.pctools.com)—enable you to specify keys that the program should ignore.