How do I register a command on the desktop background context menu? (And how do I remove one I don’t like?)

Raymond Chen

To register a command to appear on the context menu for the desktop background, you put it under the predefined shell object Desktop­Background. (For some reason, this predefined object is not on the list of predefined objects, although its existence is betrayed on this page.) As with all progids, simple commands can be registered under the shell key; complex commands can be registered under the shellex key. For example, this registration adds an entry called CharMap that runs, um, CharMap. In case you wanted to be able to launch CharMap right from the desktop context menu.

[HKEY_CLASSES_ROOT\DesktopBackground\shell\CharMap\command]
@="charmap.exe"

Many shell extensions choose to register under Directory\Background, and then perform a test at runtime to see if the directory is the desktop. If so, then they add the extension; if not, they suppress it.

Therefore (reading the contract from the other side), if you want to remove an item that some random third party added to your desktop context menu (for some reason, video card manufacturers love adding stuff to the desktop context menu), you can go spelunking into

HKEY_CLASSES_ROOT\
    DesktopBackground\

and

HKEY_CLASSES_ROOT\
    Directory\
        Background\

When I do this, I prefer not to delete the registry key entirely, because who knows, maybe someday I want to re-enable it. In the case of a context menu shell extension, I disable it by reversibly corrupting the CLSIDs.

HKEY_CLASSES_ROOT\
    DesktopBackground\
        shellex\
            ContextMenuHandlers\
                x{########-####-####-####-############}\
                    @="x{########-####-####-####-############}"

HKEY_CLASSES_ROOT\
    Directory\
        Background\
            shellex\
                ContextMenuHandlers\
                    x{########-####-####-####-############}\
                        @="x{########-####-####-####-############}"

By putting an x in front of the curly brace, I prevent the key name or value from being parsed successfully as a CLSID, but I can easily re-enable the extension by removing the x.

Note that most registrations will not have two CLSIDs. Some will put a CLSID in the key name, and others will put the CLSID as a value under the key. So whichever one you see, stick an x in front.

0 comments

Discussion is closed.

Feedback usabilla icon