When extending the Windows' shell context menu (e.g. for adding an 'Open command here' prompt on directories), a 'command' key needs to be created in the registry.

The value of this 'command' key apparently can be any valid command line.

I want to know which 'special variables' are available for use inside this command line.

For example, I use following command for opening and cmd window from within a directory's context menu (*):

cmd.exe /e:on /f:on /s /k pushd "%V"

I cannot find any reference to what %V actually means or what the full list of such variables is.


(*) Following registry keys are created for this: [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\shell\cmdshell] @=Open Command Prompt Here"

HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\shell\cmdshell\command] @="cmd.exe /e:on /f:on /s /k pushd \"%V\""

link|improve this question
feedback

3 Answers

Here is the arguments/syntax for cmd.exe

/k carries out the command specified by the following string so it executes the command pushd %V and since the only argument pushd accepts is a path it follows that %V a variable delivered by explorer that contains the path of the folder right clicked.

link|improve this answer
feedback

This question intrigued me so I did some experimenting. I have a folder C:\iso. What I found when I did the right-click thing:

D = C:\iso
H = 0
I = :115057472:7932
L = C:\iso
S = 1
V = C:\iso
W = C:\

I returned a different set of numbers on every try. H was always 0 and S was always 1. D, L, and V were all the target folder. W was the parent of the target folder. Anyone care to expand on this?

FYI: I used the following registry entries to test:

[HKEY_CLASSES_ROOT\Directory\shell\testcmd]
@="Test Command Window Directory"
[HKEY_CLASSES_ROOT\Directory\shell\testcmd\command]
@="cmd.exe /k \"echo %A`%B`%C`%D`%E`%F`%G`%H`%I`%J`%K`%L`%M`%N`%O`%P`%Q`%R`%S`%T`%U`%V`%W`%X`%Y`%Z\""

(The ` characters were used for delimiters)

link|improve this answer
feedback

It is indeed hard to find what %V means or a list of those variables, through Google I have found that there seems to exist a %L too. I don't think you have to pass more than %V or %L though to a prompt, as there is no other useful information I think. Where %V could be the directory name, %L could be a location to a file. Doing an 'echo' could help when in doubt...

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.