Windows – In HKCR, what is difference between Directory and Folder in context menu config

shell-extensionswindows xp

Following up on this question over at SO (How do I open cmd window in specific location?) I'm looking for an effective way to add the Open Command Prompt Here shortcut to a context menu. Various solutions propose adding entries to HKCR\Folder and others suggest adding entries to HKCR\Directory.

Based on this question (Directory Vs. Folder) it seems a folder could be virtual or not while a directory is always "real". A ven diagram would have folder being a large circle and directory a smaller circle completely enclosed within the folder circle.

For the sake of a command prompt, is it correct to assume I'll probably only be dealing with "real" folders, or directories?

The questions then are as follows:
Can I open a command prompt window in a virtual directory and what conceivable reason would I have for doing this?
Would adding a context menu item ONLY to HKCR\Folder cover all my bases and then some?
Would adding a context menu item ONLY to HKCR\Directory end up missing some things?

Finally, for brownie points:
What if I wanted to be able to add an entry to open a command prompt by clicking inside a folder rather than on a folder icon, which context menu item would I have to use to get this function?

Best Answer

  • The best way I did it was add the Open command prompt to all objects. The open command prompt passes the working directory (cmd /k pushd %d") and you get the command prompt on the working directory of the object you right clicked.

    For the most part, you CAN open a command prompt in a virtual folder. It depends though. For example, DFS folders return a command prompt at a UNC. But trying to get a command prompt on an object in a search folder just gets you the real location of the object.

    Edit:

    To get the command prompt when you right click the background requires that you write a shell extension. And since Microsoft insists shell extensions be written in native code !me :( See the MSDN on the shell extension menu.

    http://msdn.microsoft.com/en-us/library/cc144067(v=vs.85).aspx

    Or you could just download this program: Context Console Shell Extension.

    http://code.kliu.org/cmdopen/