It is possibe to create context menu entries for Window's File Explorer for all files by creating registry entries such as
[HKEY_CLASSES_ROOT\*\shell\kdb-test]
@="Test (*,kdb-test)"
[HKEY_CLASSES_ROOT\*\shell\kdb-test\command]
@="cmd.exe /c type %1 & pause"
It is also possible to create them for a given extension by replacing \* \
by \.extension\
.
However, I have found that the latter doesn't work reliably. For instance,
[HKEY_CLASSES_ROOT\.regshelltest\shell\kdb-test]
@="Test (.regshelltest,kdb-test)"
[HKEY_CLASSES_ROOT\.regshelltest\shell\kdb-test\command]
@="cmd.exe /c type %1 & pause"
will override the difinition for *
, as intended, but doing the same for .pdf
or .txt
won't work on my system.
The documentation suggestest as clean solution to use an indirect structure instead,
[HKEY_CLASSES_ROOT\.txt]
@="PlainTextFile"
[HKEY_CLASSES_ROOT\PlainTextFile\shell\kdb-test]
@="Test (PlainTextFile,kdb-test)"
[HKEY_CLASSES_ROOT\PlainTextFile\shell\kdb-test\command]
@="cmd.exe /c type %1 & pause"
but that doesn't work either. Additionally, it reduces compatibility, as it strongly assumes that everyone defining such registry entries uses the same file type name for the extension (couter-example: .pdf being set to PDFXChangeEdit.PDF
), so defining the actions based on the extension would be preferable – especially for user-created shell extensions.
A similar issue was discussed in “Registry keys for context menu entries written, but no context menu entries”, but there the suggested solution is to query the "ProgID" (i.e. the file name type as specified by the HKEY_CLASSES_ROOT\.extension
key), which didn't work for me.
Is there some reliable way to create these context-menu entries based on file-extensions, that doesn't depend on the ProgID
set?
As a workaround, in “Add a Windows Shell context menu entry for a specific extension (not file type)” it has been suggested to use the \*\
key with the AppliesTo
filter. It does however feel like a workaround rather than a clean solution, so I am looking for a possibility to cleanly and reliably use the HKEY_CLASSES_ROOT\.extension\shell
interface.