Jump to content

How to make a "ContextMenuHandlers" key


zappelectric19

Recommended Posts

I have XP-Pro SP2 (x86) and XP-Pro SP3 (x86) on my laptop and desktop respectively.

How can I add a subkey to the "HKEY_CLASSES_ROOT\Directory\Background\shellex\ContextMenuHandlers" key?

I want to add "Show Desktop" to the "Background context menu"as I have done for the "HKEY_CLASSES_ROOT\Folder\shell" and the "HKEY_CLASSES_ROOT\*\shell" Registry keys.

But this failed.

I am thinking I have to make my own "ContextMenuHandlers" subkey because the subkeys there such as the one below do add items to the Background Context Menu

"HKEY_CLASSES_ROOT\Directory\Background\shellex\ContextMenuHandlers\New"

So maybe someone here could show me how to create a "ContextMenuHandlers" subkey to add "Show Desktop"

to the Background Context Menu.. Thank you.

How can I add this "Show Desktop" item to the Background Context Menu displayed wehen I right click on an empty space either on the desktop or in a Windows Explorer window?

I used the method outlined below to add the "Show Desktop" to the file and folders context menus'

1. I wrote "Show Desktop.scf"and placed it in "C:\Program Files\Show Desktop"

2. I wrote "Show Desktop.BAT"and placed it in "C:\Program Files\Show Desktop"

3. I wrote "Show Desktop BOTH.reg", ran an merged it into the Registry.

This is the "Show Desktop BOTH.reg"

 Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Folder\shell\!Show Desktop]
@="!Show Desktop"

[HKEY_CLASSES_ROOT\Folder\shell\!Show Desktop\Command]
@="\"C:\\Program Files\\Show Desktop\\Show Desktop.BAT\""


[HKEY_CLASSES_ROOT\*\shell\Show Desktop]
@="Show Desktop"

[HKEY_CLASSES_ROOT\*\shell\Show Desktop\Command]
@="\"C:\\Program Files\\Show Desktop\\Show Desktop.BAT\""

This is the "Show Desktop.BAT" used for the value for the Command subkey above:

   start "" "C:\Program Files\Show Desktop\Show Desktop.scf"
exit

This is the "Show Desktop.scf" in the "Show Desktop.BAT" file above:

 [Shell]
Command=2
IconFile="C:\Program Files\Show Desktop\Show Desktop.ico"
[Taskbar]
Command=ToggleDesktop

I tried adding the subkeys and values below

    [HKEY_CLASSES_ROOT\Directory\Background\shell]

[HKEY_CLASSES_ROOT\Directory\Background\shell\!Show Desktop]
@="!Show Desktop"

[HKEY_CLASSES_ROOT\Directory\Background\shell\!Show Desktop\Command]
@="\"C:\\Program Files\\Show Desktop\\Show Desktop.BAT\""

to the "HKEY_CLASSES_ROOT\Directory\Background" key.

But this failed.

I am thinking I have to make my own "ContextMenuHandlers" subkey because the subkeys there such as the one below do add items to the Background Context Menu

"HKEY_CLASSES_ROOT\Directory\Background\shellex\ContextMenuHandlers\New"

So maybe someone here could show me how to create a "ContextMenuHandlers" subkey to add "Show Desktop"

to the Background Context Menu.. Thank you.

Link to comment
Share on other sites


Instead of the batch file, i'll do an autoit .exe:

sd.au3:

send("#d",0)

and it should work like a charms if you compile the autoit file au3.

As for the problem, you're trying to launch a script from the command key and it is expected to be an exe i think.

Edited by allen2
Link to comment
Share on other sites

What happens when you double click your batch file (physically). Does it actually toggle the desktop, all I get is a CMD window flash on screen and nothing else.

So far, the .scf only toggles my desktop if I actually click it, it does not run from the 'Run' box, or when I tried to run it from cmd.exe

Maybe this is a limitation of the .scf script format, that it cannot run from batch files. (cmd.exe)

------------------------------------------------------

Check to see which file format or character encoding your text editor is set to. When mine is set to Unicode and the

BAT files are saved that way they don't work.

Did you copy this text:

[shell]

Command=2

IconFile="C:\Program Files\Show Desktop\Show Desktop.ico"

[Taskbar]

Command=ToggleDesktop

amd save it as "Show Desktop.scf" in a folder named "Show Desktop" in your "Program Files Folder"?

You can save it anywhere you want, but the BAT file must be coded with the correct path to "Show Desktop.scf"

example: start "" "PATH TO FOLDER WHERE SAVED\Show Desktop.scf"

Here is a vbs script to also toggle the desktop

ToggleDesktop.vbs

------------------------------------

Option Explicit

Dim objShell

Set objShell = CreateObject("Shell.Application")

objShell.ToggleDesktop

Set objShell = Nothing

--------------------------

Just now, I copied the above script with Notepad and saved it to my Desktop as "ToggleDesktop.vbs" (Without quotation marks of course. I then wrote the "ToggleDesktop.BAT" file below and saved it.

The "C:\Documents and Settings\Administrator\Desktop\ToggleDesktop.vbs" is the path to the "ToggleDesktop.vbs"

file on my desktop. I double clicked the BAT file and everything minimized! Try using this "ToggleDesktop.vbs"

script instead of the "Show Desktop.scf" script. I think I read somewhere the "Show Desktop.scf" wasn't functioning on some XP SP3 machines. The vbs script is supposed to work on Win 98 through Windows 7.

ToggleDesktop.BAT

============================================================================================

start "" "C:\Documents and Settings\Administrator\Desktop\ToggleDesktop.vbs"

exit

===================================================================================

For the Record:

I know I can Show Desktop other ways, that is not my point or quest.

I am quite aware of the Show Desktop on the Quick Launch Bar. That is where I got the script. I am also aware of the WinKey+D and many other shortcuts to minimize all or show desktop. I want to find out how to add an item to the Background context menu. Although I would like the Show Desktop item, I really don't care if the item started "my_momma's.exe" I mainly would like to learn how to do it. I figure If I can find out how to run an application from that menu, then I could run a bunch of scripts if I chose by converting them to exe files. There are items added there by external applications I have installed.So if they can do then I should be able to as well.

Link to comment
Share on other sites

Well, you missed my point, subtlety for the loss. You were supposed to double click your batch file and learn for yourself that the problem was in the .scf and not your shell entry. So I will go into detail.

So maybe someone here could show me how to create a "ContextMenuHandlers" subkey to add "Show Desktop"

to the Background Context Menu.. Thank you.

This cannot be done that way, you'll need to use the shell, not the shellex. shellex\ContextMenuHandlers is for using a CLSID to specify a DLL that in turn creates the context menu entry programmatically. This pic shows a normal shellex entry.

rclick_19.png

Not sure what you are on about in your last post, you already know how to create a shell entry, you just don't know you know it. The only reason your first shell entry failed is because your batch file cannot use .scf files, not because the registry was done wrong. Capisce?

-------------------------------------------------------

Want to bet I can't run a .scf file from a batch file?

This BAT file

---------------------------

start "" "C:\Program Files\Show Desktop\Show Desktop.scf"

exit

----------------------------------

shows my desktop whenever it is clicked

these reg entries

---------------------

[HKEY_CLASSES_ROOT\Folder\shell\!Show Desktop]

@="!Show Desktop"

[HKEY_CLASSES_ROOT\Folder\shell\!Show Desktop\Command]

@="C:\\Program Files\\Show Desktop\\Show Desktop.BAT"

--------------------------

Allow me to show desktop from context menu when right clicking on a folder.

Did you try your background shell registry keys? I did and

as before when I add my own, the background context menu did not

show the Show Desktop item. I would not have posted here if that had worked.

Even though I can run Show Desktop.scf from a bat file and run that bat file from

a context menu regardless of what you may believe, I use a vbs script which I convert into an exe file to add Show Desktop to my Folder and my File context menus

Link to comment
Share on other sites

OK, my bad, I have cleaned up my previous posts, they really don't apply to XP. But I have an an answer with good and bad news.

#1) Good news, you are not crazy, the .scf/batch combo is working from XP. I was on Windows 7 (your batch does not work on 7), but you were adamant that it is working so I plugged in a VM and what do you know, it works fine in XP.

#2) Bad news, apparently the Directory\Background\Shell setting is not recognized until Vista\Windows 7, it simply does not work in XP. Unfortunately this means that in XP there is no easy way to do this.

Unless anyone has an alternative method to access it from the registry (HKCR\Folder ? probably not), your next best bet is going to be writing a COM object. Do you have programming experience ? and is it really worth it ?

Edited by MrJinje
Link to comment
Share on other sites

Thanks for checking out what I said and for the "My Bad". I learned from you how to

deal with things I have posted incorrectly. I found I couldn't delete the posts. So in the

future I will replace the incorrect text with a "N/M". BTW what does "N/M" stand for?

Now as for my "ContextMenuHandlers" request, I thank everyone who has taken the time to offer

their help and suggestions. From the information presented here I can see making my own

"ContextMenuHandler" requires a much greater knowledge of programming than the meager amount

I possess. Rather than attempt to gain the necessary knowledge, I am going to abandon this project.

It is way too complicated. Again I thank all of you.

Link to comment
Share on other sites

Yeah, the old spidey sense didn't kick in 'til you confirmed the reg setting didn't work on XP.

N/M is short hand for 'nevermind', 'no message', or 'not meaningful'.

Edited by MrJinje
Link to comment
Share on other sites

As i had a little time today, i modified the dll and made it to run an exe named customcommand.exe (create one if needed with autoit or another compiler) and it must be in c:\windows\system32.

The attached dll might be stored where you want and then must be registered with regsvr32.

Link to comment
Share on other sites

Thanks Allen2, working good on XP.

customcommands.png

Would you mind zipping up your source, I have the original from code-project, thinking the easiest way for me to learn, is to windiff the two sources and see what bits you changed.

Also, which C++ compiler would you recommend, looking for lightweight, I'd like to avoid 2010 Express if at all plausible.

Edited by MrJinje
Link to comment
Share on other sites

Thanks Allen2, working good on XP.

customcommands.png

Would you mind zipping up your source, I have the original from code-project, thinking the easiest way for me to learn, is to windiff the two sources and see what bits you changed.

Also, which C++ compiler would you recommend, looking for lightweight, I'd like to avoid 2010 Express if at all plausible.

Here it is: ShellExtGuide7_customcommands.zip

I'm currently using an old Visual C++ 6 compiler (for this kind of job) which is more than enough because i don't use it too much but i prefer mingw that i use more often for console applications.

Link to comment
Share on other sites

  • 3 years later...

As i had a little time today, i modified the dll and made it to run an exe named customcommand.exe (create one if needed with autoit or another compiler) and it must be in c:\windows\system32.

attachicon.gifDirBkgndExt.7z

The attached dll might be stored where you want and then must be registered with regsvr32.

Please can send me DirBkgndExt.7z?

pr post it again, please...

Many thank

Link to comment
Share on other sites

As i had a little time today, i modified the dll and made it to run an exe named customcommand.exe (create one if needed with autoit or another compiler) and it must be in c:\windows\system32.

attachicon.gifDirBkgndExt.7z

The attached dll might be stored where you want and then must be registered with regsvr32.

Please can send me DirBkgndExt.7z?

pr post it again, please...

Many thank

Please can send me ShellExtGuide7_customcommands.zip?

pr post it again, please...

Many thank

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...