I have created a custom command entry in the registry to add an item to the Windows Explorer context menu when the user right-clicks on a folder. Here is exactly what the value looks like in the registry:
"C:\Program Files\Directory Switcher\DirectorySwitcher.exe" "%V" "2021.0"
%V
returns the current directory. If the directory path has any folders with spaces in the name it causes the path to split into additional command line arguments. To get around this, Microsoft tells you put quotes around it "%V"
.
The specific issue is that when %V is at the drive root, the backslash in C:\ escapes the end quote and causes the rest of the command line parameters to be parsed incorrectly. For example, at C:\ I get a single argument C:" 2021.0
rather than the expected two of C:\
and 2021.0
.
How do I properly encapsulate %V so that it works for normal folder paths and drive roots that end with a backslash? The alternative is to change my program to look for this edge case but I would rather understand how to correct my shell verbs.
(Information about %V can be found at this SuperUser question)
Official Microsoft documentation about shell command strings can be found here