Why can't I pass the location of my right click as argument if I'm not clicking on an object?

1

Why can't I pass the location of my right click to a program as an argument if I am not right clicking on an object?

My Test set up: Windows 10, I have DebugViewer running and my program something.exe will output any arguments it receives to debug.

I set up these registry entries in the:

Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Directory\Background\shell\TestYo2]
@="Directory Test"
[HKEY_CLASSES_ROOT\Directory\Background\shell\TestYo2\command]
@="c:\\something.exe %1"

Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\txtfile\shell\Try This]
@="Txt Menu"
[HKEY_CLASSES_ROOT\txtfile\shell\Try This\command]
@="c:\\something.exe %1"

RESULTS: When I right click on a text file and select my "Txt Menu" from the context menu fires up my program and passes it the file path to the text file. The location of the text file I right clicked on is printed to debug.

If I right click on the background of an opened directory and select my "Directory Test" this message is displayed: 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. My program is never fired up.

What gives?

Core2

Posted 2017-08-07T15:36:20.180

Reputation: 41

Answers

1

So the solution is this:

Add a new key called NoWorkingDirectory and leave the data blank.

In the command line %1 becomes a %V

Now when I right click the background and select my menu item, it launches my program and passes to the program an argument containing the location of where the right click just took place. done.

found it via this post: Windows shell add item to context menu when click on blank part of folder

Core2

Posted 2017-08-07T15:36:20.180

Reputation: 41