How to exclude libraries from custom right-click menu entries using AppliesTo string?

Jonathan Woodward 26 Reputation points

I want to add a custom context menu entry to open an administrator command prompt when right-clicking a directory or directory background. I borrowed the registry modification code (shown below) from tenforums and works fine.

However, I found that the command prompt context menu is also added to library folders and backgrounds. It seems that command shell windows cannot be open in such a way for hardlinks like Libaries. Note that no registry information was entered for the HKCR\LibraryFolder\Background\Shell, HKCR\AllFileSystemObjects\Shell nor HKCR\Folder\Shell subkeys.

I would like to exclude Libraries and Library backgrounds from displaying the command prompt context menu and think I can do so using the AppliesTo string, but don't know how the proper syntax for values. If I simply add AppliesTo string with value "NOT Libraries" to HKCR\Directory\shell\CommandPrompt\shell\cmdadmin and/or Directory\Background\Background\shell\CommandPrompt\shell\cmdadmin subkeys, the right-click menu entries disappear for ALL folders and/or folder backgrounds.


  1. What is the proper format/syntax for the values of AppliesTo string to exclude the custom context menu entry from library folders and library backgrounds?
  2. Does the AppliesTo string need to be added to either HKCR\Directory or HKCR\Directory\Background or both keys?



@="Open here as administrator"

@="cmd /c echo|set/p=\"%V\"|powershell -NoP -W 1 -NonI -NoL \"SaPs 'cmd' -Args '/c \"\"\"cd /d',$([char]34+$Input+[char]34),'^&^& start /b cmd.exe\"\"\"' -Verb RunAs\""

@="Open here as administrator"

@="cmd /c echo|set/p=\"%V\"|powershell -NoP -W 1 -NonI -NoL \"SaPs 'cmd' -Args '/c \"\"\"cd /d',$([char]34+$Input+[char]34),'^&^& start /b cmd.exe\"\"\"' -Verb RunAs\""

Windows 10
Windows 10
A Microsoft operating system that runs on personal computers and tablets.
10,828 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Еgі-RаZоRZ 6 Reputation points

    Hello @Jonathan Woodward and @Sunny Qi ,

    I am currently experimenting with the AppliesTo and DefaultAppliesTo registry commands, which I have just found out, based on the very few references in the registry. (Based off the "BitLocker" and the non-official "Take Ownership" entries)

    I have pulled off quite a few interesting hat-tricks with these ones so far, such as mounting an ISO with DAEMON Tools by default, yet opening it as a regular folder inside an archive, with the use of TC4Shell (full Explorer integration for archives - off-topic, paid program - check it out), using RunAs as an option to also mount it with DAEMON Tools from within the archive. :p

    Now, back to the topic ...

    UPDATE: AppliesTo & DefaultAppliesTo DO NOT WORK at Directory Background locations‼ This includes Library backgrounds and such.

    And so, I believe « NOT System.Kind:~Library » is the right command. I am unsure about Library backgrounds, and believe it is not feasible unless there IS another undocumented ID for this one.

    I have experimented under the Folder key, with success on the Library folders. (Although I do not really need Library for my MODs, I have kindly tested it out for ya) - Again I am unsure about the Directory key, but you may feel free to experiment with the command I found out :p

    I have found this command by guessing based on your input and that of others, yees the AppliesTo & DefaultAppliesTo commands are very interesting ones, but heavily undocumented :p

    Goodbye! poof
    The Egi-RaZoRZ.

    Small but very worthy edit: My incompetence has no limits. Hah! Joke
    While finding out about the "NOT System.Kind:~Library" entry, I've just noticed my «Open with...» duplicate also disappeared from my Folders. hehe. whoops =p
    But then I remembered about them parentheses and it worked!
    Thus, get this: New entry! ie. « AppliesTo: NOT (System.Kind:~Library) AND (System.Kind:~System.Kind#folder) » Note the parentheses added around entries.

    Feel free to adjust according to your needs, I need to read the question again lol. Always glad to help for anything.


    ** EDIT: Added parentheses around System.Kind:~Folder

    1 person found this answer helpful.