Logo
programming4us
programming4us
programming4us
programming4us
Home
programming4us
XP
programming4us
Windows Vista
programming4us
Windows 7
programming4us
Windows Azure
programming4us
Windows Server
programming4us
Windows Phone
 
Windows Vista

File Type Associations (part 4)

- Windows 10 Product Activation Keys Free 2019 (All Versions)
- How To Bypass Torrent Connection Blocking By Your ISP
- How To Install Actual Facebook App On Kindle Fire
10/18/2011 5:50:53 PM

4. Lock Your File Types

Tech companies used to spend millions trying to get you to buy their products (OK, they still do), but now the race is on to be "the default." Microsoft wants its Live Search web site to be the default search engine in IE, and Google sued Microsoft to try to prevent this before Windows Vista shipped. Companies pay PC manufacturers to preinstall trial versions of their software on all their machines so their products can be the default. And when you install an application on your PC, the installer invariably makes the new program the default for all the file types it supports.

Why is being the default so important? Because people don't change the defaults.

As a result, software companies—Microsoft included—make a habit out of steamrolling over your preferences to promote their own products. Luckily, you have a defense, and it takes place in the Registry.

There are basically two approaches to protecting your file types: you can back them up so they can be restored in case they're ever overwritten, and you can "lock" them, preventing such changes in the first place.

The easiest way to back up your file types is to create Registry patches. For instance, if you're backing up the file type for plain-text (.txt) files, your Registry patch should include all of these keys:
HKEY_CLASSES_ROOT\.txt
HKEY_CLASSES_ROOT\txtfile
HKEY_CLASSES_ROOT\SystemFileAssociations\text

That last one—the one in the SystemFileAssociations branch. And if you want to include other related filename extensions, such as .log, .ini, and .csv (to name a few), you'll want to include those keys as well.

So, if your file type associations for text files ever get wiped out, just double-click your Registry patch backup to restore them.

But a slicker solution is to lock your file types by setting restrictive permissions on the aforementioned keys. That way, no application, no installer, and not even Windows itself can change them unless you unlock them first.

If you want a shortcut, you can use File Type Doctor, introduced in the previous section. Just highlight the file type you want to lock and click the Lock button. File Type Doctor will not only protect the selected filename extension and associated file type with one click, but all linked filename extensions as well.

To remove the lock, just select a locked file type (you can click the leftmost column header to group all locked file types together) and click the Unlock button.

5. Expand the Scope of Your File Types

To every rule there's an exception, the basic file types system is laid out, with a collection of keys named for filename extensions (e.g., HKEY_CLASSES_ROOT\.jpg) and the corresponding file type keys (such as HKEY_CLASSES_ROOT\jpegfile). As it turns out, there's yet another connection in the Registry that affects your file types.

Many extension keys—like HKEY_CLASSES_ROOT\.jpg—contain values named PerceivedType, which point to subkeys of HKEY_LOCAL_MACHINE\SOFTWARE\Classes\SystemFileAssociations. The keys therein work like ordinary file type keys, but they're much broader in scope. Instead of being linked to one or two filename extensions, a perceived type key could be linked to dozens.

Say you just installed a new image-resizing utility that you'd like to use with a variety of photo formats. But rather than make it the default for those file types, you decide to add a context menu item for each supported file format (e.g., .jpg, .bmp, .png, and so on). Sure, you can do this for each of the 10 or so graphic formats it supports, but it turns out that all you need to do is add it to this key to affect all your image files at once:

HKEY_LOCAL_MACHINE\SOFTWARE\Classes\SystemFileAssociations\image\shell\my_new_
program



By default, the image key shown here is linked to all filename extensions with a PerceivedType set to image, namely .bmp, .dib, .emf, .gif, .ico, .jfif, .jpe, .jpeg, .jpg, .png, .rle, .tif, .tiff, .wdp, and .wmf.

Windows Vista comes with only five perceived type keys (audio, image, system, text, and video) out of the box, but you can add your own to the SystemFileAssociations branch at any time, provided you then link at least one file extension to it by adding a PerceivedType value pointing to your new key. The benefit is that you can use this key to add a custom context menu item that affects a large number of different file types at once. The drawback is that it's one more place you'll have to look to track down a misbehaving or unwanted context menu item.

To break the connection between a filename extension and a perceived type, just delete the PerceivedType value from the extension key. Or, to link up a file type with an existing PerceivedType, create a new string value named PerceivedType in the extension key, and set its contents to the name of the matching perceived type key in the SystemFileAssociations branch.

File Type Doctor  also supports perceived types through its "scope" and "affiliation" features. For instance, if you try to delete a context menu action that's connected through a perceived type, File Type Doctor displays a confirmation box that lists the other filename extensions that will be affected by the change. Likewise, when creating a new action, you can choose the scope; click the Properties button next to the Scope list to display all the extensions tied to the current selection.

While you're digging around the HKEY_CLASSES_ROOT\SystemFileAssociations branch in the Registry, you may find some file extension keys here as well, like HKEY_CLASSES_ROOT\SystemFileAssociations\.png. These look and work just like the extension keys and file type keys in HKEY_CLASSES_ROOT, but they're used primarily to reference the Windows Explorer extensions that were preinstalled with Windows. Why they're here instead of in HKEY_CLASSES_ROOT with the rest of the extensions is not entirely clear, but what is clear is that the SystemFileAssociations branch is yet another place to look for Registry keys that affect file types.

6. Customize Windows Explorer's New Menu

If you right-click an empty area of the desktop or any open folder window and select New, you'll see special list of registered file types that can be created on the spot. Choose one, and Explorer will create a new (usually empty) file with the appropriate filename extension right there. Not surprisingly, you can edit that list, and even make it do more than just create empty files.

Here's the easiest way to remove unwanted items from Explorer's New menu:

  1. Install Creative Element Power Tools , turn on the Edit file type associations option in the Creative Elements Power Tools Control Panel, and click Accept.

  2. Right-click an empty area of your desktop, select New, and then select one of the entries you'd like to remove.

  3. Right-click the new file and select Edit File Type.

  4. Remove the checkbox next to the Show in Explorer's New menu option.

  5. The change will take effect immediately; right-click the desktop again and select New to check it out.

If you want to do it by hand, you'll need to look in a few different places in the Registry:

  1. Open the Registry Editor.

  2. Navigate to the key named for the filename extension you'd like to remove from Windows Explorer's New menu. For the .txt extension, you'd go to HKEY_CLASSES_ROOT\.txt.

  3. If you see a subkey here named ShellNew, rename it to Shellnew- (Shellnew followed by a hyphen).

  4. Next, look at the (Default) value of the extension key, and then look for a subkey that matches the contents of the (Default) value. Again, for the .txt extension, you'd go to HKEY_CLASSES_ROOT\.txt\txtfile.

  5. As in step 3, if you see a subkey here named ShellNew, rename it to Shellnew- (Shellnew followed by a hyphen).

  6. The change will take effect once you close the Registry Editor; right-click the desktop and select New to check it out.

As you can see, it's merely the presence of a ShellNew key that determines whether a file type shows up in Windows Explorer's New menu. (Actually, it's a little more complicated than that, but more on that subject later.)

Now, there are some nifty hacks you can use on the ShellNew keys you choose to leave intact. A standard ShellNew key has only one value (NullFile, described in the upcoming list), but if you add any of the other following values to the ShellNew key, you'll change how Windows Explorer behaves when you select the corresponding items from its New menu. All values are string values unless otherwise specified:

Command

If you include the full path and filename of a program executable (.exe file), Explorer will launch the program instead of creating a new file. Make sure to include the "%1" parameter  so the target program knows where to create the new file, like this:

c:\windows\system32\notepad.exe "%1"
Consult your application's documentation to see whether any other command-line parameters are needed to create the new document; otherwise, the program may just open and complain that it can't find the (as yet nonexistent) file.
Data

Any text stored in this binary value will be placed into the new file. For instance, the Data value for .rtf files (in HKEY_CLASSES_ROOT\.rtf\ShellNew) contains the text, {\rtf1}, which ensures that the new .rtf file is readable by whatever program you use to open it. Explorer ignores the Data value if either FileName or NullFile is specified.

FileName

This is the full path and filename of a template file—a file to be copied and used for each new document you create—in lieu of creating an empty (zero-byte) file. If you don't include the path, Windows looks in C:\Users\{your_user_name}\AppData\Roaming\Microsoft\Templates as well as C:\Windows\ShellNew for the template file.

Handler

The Class ID (e.g., {CEEFEA1B-3E29-4EF1-B34C-FEC79C4F70AF}) of the shell extension used to create the new file. For example, Windows Shortcuts (.lnk files) use a handler.

IconPath

The full path and filename (plus the icon index) of the icon that appears next to the item in Windows Explorer's New menu.

ItemName

By default, the name of the new file you create is the name of the file type, preceded by the word "New" and followed by the appropriate filename extension; for instance: New Text Document.txt. This value determines the name of the new file, but like MenuText, described next, it must point to a text resource in a .dll file.

MenuText

Unfortunately, this is not what it looks like. Yes, it determines the text that appears in Explorer's New menu, but you can't just type the text here. Instead, it must be a reference to a text resource in a .dll file, such as @%systemroot%\system32\mspaint.exe,-59414.

NullFile

This instructs Explorer to create an empty (zero-byte) file. If none of these other values are present, you need to include the NullFile value, or the file type won't show up in Explorer's New menu.

So, how do you keep applications from recreating the ShellNew keys and continuously cluttering up Explorer's New menu? Adobe Photoshop does this every time it starts, but all it takes is a quick change to the Registry to prevent it from happening again:

  1. Open the Registry Editor.

  2. Navigate to the extension key you want to permanently exclude from the New menu. For Photoshop documents, you'd go to HKEY_CLASSES_ROOT\.psd.

  3. Delete any ShellNew keys you find here; see the solution spelled out earlier in this section for details.

  4. Right-click the extension key (e.g., .psd), and select Permissions.

  5. In the Permissions window, click the Advanced button, and then in the Advanced Security Settings window, click Add.

  6. Next, in the Select User or Group window, type everyone into the Enter the object name to select field, and then click OK.

  7. Finally, in the Permission Entry window, place a checkmark in the Deny column for Create Subkey, and then click OK when you're finished.

  8. Click OK, then click Yes when asked whether you're sure you want to set a "deny permissions entry," and then click OK to close the final window.

  9. The change will take effect immediately. Test it out by starting the application; you can press F5 in the Registry Editor to refresh the view and confirm that no new ShellNew subkey has been added.

You can accomplish pretty much the same thing with File Type Doctor's Lock feature , but that may be overkill if all you want to do is keep unwanted items out of Explorer's New menu.

7. Fix Internet Shortcuts

Customization is fun, but sometimes all you need to do to a file type is fix it when it breaks. Most of the time you can just reinstall the application that originally created it—unless a UserChoice key is in effect, explained in the "The Evils of UserChoice" sidebar—but that doesn't always work.

One file type that's always getting munged is the .url (Internet Shortcut) type, and repairing it can be a little tricky. For one, .url files don't launch your web browser directly; instead, they activate a Windows .dll that does the launching. In essence, it's a two-step process that employs two different file types; the following sequence of Registry keys shows how it works.


  1. Go to HKEY_CLASSES_ROOT\.url, and confirm that the (Default) value is set to InternetShortcut.

  2. Next, go to HKEY_CLASSES_ROOT\InternetShortcut\Shell\Open\Command, and make sure the (Default) value here is set to:

    rundll32.exe shdocvw.dll,OpenURL %l

  3. Internet shortcuts also use an "icon handler" by default , which chooses an icon for each file depending on the type of URL inside. So, this key:

    HKEY_CLASSES_ROOT\InternetShortcut\ShellEx\IconHandler

    should be set to {FBF23B40-E3F0-101B-8488-00AA003E56F8}. Of course, if you want to disable the icon handler and choose your own static icon instead, just rename the IconHandler key to IconHandler.backup, and then specify your icon file in the DefaultIcon key.

  4. Once Windows has determined what type of URL it's dealing with, it executes the Open command in the key named for the protocol being used. For instance, the URL http://www.annoyances.org/ uses the http:// protocol, so its default application is stored in this Registry key:

    HKEY_CLASSES_ROOT\http\shell\open\command

    There are similar keys for the other protocols, like https://, file://, ftp://, news://, nntp://, snews://, telnet://, and mailto:. (In File Type Doctor, the protocol file types are found at the bottom of the list.) These keys aren't just used for Internet Shortcuts; they control Vista's behavior whenever you try to open a web address by clicking a hyperlink in an email message or typing a URL into the Start menu's Search box.


  5. The (Default) value of the protocol's command key should be set to the full path and filename of your default web browser. Vista's default is, of course, Internet Explorer:

    "C:\Program Files\Internet Explorer\iexplore.exe" -nohome

    Or, if you want Mozilla SeaMonkey to be your default browser, you'd use:

    C:\Program Files\Mozilla SeaMonkey\seamonkey.exe -url "%1"

    Or, if you're using Mozilla Firefox:

    C:\Program Files\Mozilla Firefox\firefox.exe %1


  6. The change takes effect immediately. Double-click any applicable Internet Shortcut to try out your new settings.

As you can see, there are a lot of Registry keys responsible for something as seemingly simple as opening a web address, and all it takes is one missing key, one misplaced quotation mark, or one mangled class ID to break the whole system. And so it goes with the Registry in Windows Vista.

Other -----------------
- Registry Tasks and Tools (part 5) - Back Up the Registry
- Registry Tasks and Tools (part 4) - Export and Import Data with Registry Patches & Prevent Changes to a Registry Key
- Registry Tasks and Tools (part 3) - Create an Interface for a Registry Setting
- Registry Tasks and Tools (part 2) - Find the Registry Key That Does...
- Registry Tasks and Tools (part 1) - Search the Registry & Search and Replace Registry Data
- The Registry (part 1) - The Registry Editor & The Structure of the Registry
- Custom Startups Using the Boot Configuration Data (part 2) - Using BCDEDIT to Customize the Startup Options
- Custom Startups Using the Boot Configuration Data (part 1) - Using Startup and Recovery to Modify the BCD & Using the System Configuration Utility to Modify the BCD
- Customizing and Troubleshooting the Windows Vista Startup : The Boot Process, from Power Up to Startup
- Using Control Panel and Group Policies : Implementing Group Policies with Windows Vista
 
 
Top 10
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
Popular tags
Microsoft Access Microsoft Excel Microsoft OneNote Microsoft PowerPoint Microsoft Project Microsoft Visio Microsoft Word Active Directory Biztalk Exchange Server Microsoft LynC Server Microsoft Dynamic Sharepoint Sql Server Windows Server 2008 Windows Server 2012 Windows 7 Windows 8 windows Phone 7 windows Phone 8
programming4us programming4us
Celebrity Style, Fashion Trends, Beauty and Makeup Tips.
 
programming4us
Windows Vista
programming4us
Windows 7
programming4us
Windows Azure
programming4us
Windows Server