Formatting registry values with non-standard argument syntax for context menu commands

0

I'm trying to add an entry to the Windows folder background context menu. The following "command" value works:

"P:\Projects\GuardianBlade\OfStrangerFlames\Development\Project\Bin\MakeManifest.exe"

It successfully executes MakeManifest (a tiny development tool I'm working on for my real programming project).

However, I'd like to do this:

"P:\Projects\GuardianBlade\OfStrangerFlames\Development\Project\Bin\MakeManifest.exe" -root="%1"

But that doesn't work. Neither does this:

"P:\Projects\GuardianBlade\OfStrangerFlames\Development\Project\Bin\MakeManifest.exe" "-root=%1"

What I'm aiming for, is the program MakeManifest.exe to execute, and receive one command-line argument of the format:

-root="the/directory/right-clicked/in/"

I want the quotes around the directory path to be passed into MakeManifest preserved, and I'd like the entire thing (-root="the/directory/right-clicked/in/") to be one argument.

Failing that, I'd settle for -root passed in as one argument, and the/directory/path (without quotes but as one argument) passed in as the second argument. I can't get either to work.

All my attempts result in this error message: enter image description here

"This file does not have a program associated with it for performing this action. Please install a program or, if one is already installed, create an association in the Default Programs control panel."

...as if it were trying to identify what program to execute the entire command as a filepath.

Again, setting the command without any arguments works fine.

How should I do that ?

Jamin Grey

Posted 2013-06-06T18:40:24.077

Reputation: 334

This question would be better suited for [so]. – kinokijuf – 2013-06-06T19:55:43.860

I was thinking that myself, but I wasn't sure. It's not directly programming related - it has to do with the format of shell commands on Windows. – Jamin Grey – 2013-06-06T20:15:42.817

I think it's perfectly on-topic for SU, but a possible duplicate of What is the list of special variables available when writing a shell command for a context menu

– Karan – 2013-06-06T22:14:48.693

Yea, I found that answer after kinokijuf posted! I don't think the question is a duplicate, rather I think the answer to this question is the other topic. =P I'll add the link into kino's answer. – Jamin Grey – 2013-06-06T22:29:07.773

Answers

1

Use %V instead of %1.

For additional information on shell command variables like %V and %1, see this question.

kinokijuf

Posted 2013-06-06T18:40:24.077

Reputation: 7 734

So would %V or %W be the proper usage? It seems like %V just imitates %W in certain circumstances. So should I always just use %W then, if I want the directory? – Jamin Grey – 2013-06-06T22:32:45.167

Hmm, this answer (in the linked thread) seems to imply %W actually behaves somewhat different than documented - at least in the observed results. But the poster didn't specify whether he right-clicked from within the folder, or merely on the folder icon, which might explain the deviation.

– Jamin Grey – 2013-06-06T22:38:02.037