Discussion:
Add context menu item for background of open folder window?
(too old to reply)
Paul Randall
2008-06-05 14:00:09 UTC
Permalink
I want to add a context menu item to the registry that will allow me
to right click within the white space (background) of an open folder
window and choose to open a command prompt with the same path as the
open folder window. I've searched the newsgroups and found hundreds
of references to things like "modify the right-click menu of folder
item", but these always seem refer to the context menu for a folder
icon, not for the background of an open folder window. I'm hoping
someone will post code or a URL that explains how to do it.

Thanks,
-Paul Randall
Stefan Kanthak
2008-06-05 18:19:20 UTC
Permalink
Post by Paul Randall
I want to add a context menu item to the registry that will allow me
to right click within the white space (background) of an open folder
window and choose to open a command prompt with the same path as the
open folder window.
IFF the explorer would use the shell subkey for "Background" the
following would work.

--- .REG ---
REGEDIT4

[HKEY_CLASSES_ROOT\Directory\Background\Shell\Prompt]

@="<your menu entry>"

[HKEY_CLASSES_ROOT\Directory\Background\Shell\Prompt\Command]
@="cmd.exe /K PushD %1"

[HKEY_CLASSES_ROOT\Drive\Background\Shell\Prompt]

@="<your menu entry>"

[HKEY_CLASSES_ROOT\Drive\Background\Shell\Prompt\Command]
@="cmd.exe /K PushD %1"
--- EOF ---

But explorer doesn't evaluate the shell subkey there.
Post by Paul Randall
I've searched the newsgroups and found hundreds
of references to things like "modify the right-click menu of folder
item", but these always seem refer to the context menu for a folder
icon, not for the background of an open folder window. I'm hoping
someone will post code or a URL that explains how to do it.
You'll have to write a shell extension and register that under

[HKEY_CLASSES_ROOT\Directory\Background\ShellEx\ContextMenuHandlers\<your shell extension>]
@="{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}" ; the CLSID of your shell extension handler


[HKEY_CLASSES_ROOT\Drive\Background\ShellEx\ContextMenuHandlers\<your shell extension>]
@="{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}" ; the CLSID of your shell extension handler


But leave

[HKEY_CLASSES_ROOT\Folder\Background\ShellEx\ContextMenuHandlers\<your shell extension>]

alone: "Folder" is the superset of "Directory", "Drives" and all the
virtual folders created by the various namespace handlers which
generally are not backed up by a filesystem object, so a "ChDir" or
"PushD" would fail.

Stefan
Paul Randall
2008-06-05 20:17:21 UTC
Permalink
Post by Stefan Kanthak
Post by Paul Randall
I want to add a context menu item to the registry that will allow me
to right click within the white space (background) of an open
folder
window and choose to open a command prompt with the same path as the
open folder window.
IFF the explorer would use the shell subkey for "Background" the
following would work.
--- .REG ---
REGEDIT4
[HKEY_CLASSES_ROOT\Directory\Background\Shell\Prompt]
@="<your menu entry>"
[HKEY_CLASSES_ROOT\Directory\Background\Shell\Prompt\Command]
@="cmd.exe /K PushD %1"
[HKEY_CLASSES_ROOT\Drive\Background\Shell\Prompt]
@="<your menu entry>"
[HKEY_CLASSES_ROOT\Drive\Background\Shell\Prompt\Command]
@="cmd.exe /K PushD %1"
--- EOF ---
But explorer doesn't evaluate the shell subkey there.
Post by Paul Randall
I've searched the newsgroups and found hundreds
of references to things like "modify the right-click menu of folder
item", but these always seem refer to the context menu for a folder
icon, not for the background of an open folder window. I'm hoping
someone will post code or a URL that explains how to do it.
You'll have to write a shell extension and register that under
[HKEY_CLASSES_ROOT\Directory\Background\ShellEx\ContextMenuHandlers\<your shell extension>]
@="{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}" ; the CLSID of your shell extension handler
[HKEY_CLASSES_ROOT\Drive\Background\ShellEx\ContextMenuHandlers\<your shell extension>]
@="{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}" ; the CLSID of your shell extension handler
But leave
[HKEY_CLASSES_ROOT\Folder\Background\ShellEx\ContextMenuHandlers\<your shell extension>]
alone: "Folder" is the superset of "Directory", "Drives" and all the
virtual folders created by the various namespace handlers which
generally are not backed up by a filesystem object, so a "ChDir" or
"PushD" would fail.
Thank you, Stefan. I appreciate the detailed information.

I think that writing a shell extension is beyond my capability unless
it can be done as a VBScript Windows Script Component. After reading
http://msdn.microsoft.com/en-us/library/cc144067(VS.85).aspx, I'm
thinking a WSC would not work.

-Paul Randall
Mark Pryor
2008-06-06 06:11:53 UTC
Permalink
Post by Paul Randall
I want to add a context menu item to the registry that will allow me
to right click within the white space (background) of an open folder
window and choose to open a command prompt with the same path as the
open folder window. I've searched the newsgroups and found hundreds
of references to things like "modify the right-click menu of folder
item", but these always seem refer to the context menu for a folder
icon, not for the background of an open folder window. I'm hoping
someone will post code or a URL that explains how to do it.
Winxp Power Toys has it
http://www.microsoft.com/windowsxp/downloads/powertoys/xppowertoys.mspx
http://download.microsoft.com/download/whistler/Install/2/WXP/EN-US/CmdHerePowertoySetup.exe

Mark from tlviewer.org
Paul Randall
2008-06-06 12:52:31 UTC
Permalink
Post by Mark Pryor
Post by Paul Randall
I want to add a context menu item to the registry that will allow me
to right click within the white space (background) of an open
folder
window and choose to open a command prompt with the same path as the
open folder window. I've searched the newsgroups and found
hundreds
of references to things like "modify the right-click menu of folder
item", but these always seem refer to the context menu for a folder
icon, not for the background of an open folder window. I'm hoping
someone will post code or a URL that explains how to do it.
Winxp Power Toys has it
http://www.microsoft.com/windowsxp/downloads/powertoys/xppowertoys.mspx
http://download.microsoft.com/download/whistler/Install/2/WXP/EN-US/CmdHerePowertoySetup.exe
Hi, Mark
Thanks for the link. I just assummed that M$ had not added a modifed
CmdHerePowerToy. I have now checked and verified that the current
power toy is the same old one which doesn't do what I want. I
personally think they should have called it 'open command window
THERE', because HERE would be navigated to the currently open window's
path and THERE would be navigated to the folder being pointed at.

After I have displayed a folder window, I often want to open a command
prompt window and navigate it to that same folder. I want a file
system folder window and a command prompt window, both opened to the
same folder path. If the folder is empty or there are no folder-like
items in the window, then there is no right-clickable item that has
the 'Open Command Window Here' menu item. If I navigate up one folder
level, I can then right click the icon of the folder I just got out
of, and choose 'Open Command Window Here' which opens the command
window to the place I wanted, but then I also have to navigate my
explorer folder window back to its original location if I want to see
something there while working in the command window. That is way to
much navigating to get a command window navigated to the same folder
as the original open folder window.

If the explorer window I have open includes a .zip file, which kind of
looks like a folder, then its 'Open Command Window Here' menu item
does exactly what I want, because a command window can't 'ChDir
xxx,zip' to a zip-virtual-folder window, and the command window
defaults to the folder in which the zip file resides.

I suppose one solution would be to attach the 'Open Command Window
Here' item to the context menus of everything that can be displayed in
a folder window, but I don't know what the list of 'everything'
includes, or the registry keys that would have to be modified to
include all the possible things. Being able to right click in the
white space of the background of an open explorer window and get a
'Open Command Window Here' context menu item would solve the whole
problem even for empty folders, and not clutter the context menu lists
for all the things that can be displayed in a folder window.

-Paul Randall
mayayana
2008-06-06 14:24:47 UTC
Permalink
Post by Paul Randall
I suppose one solution would be to attach the 'Open Command Window
Here' item to the context menus of everything that can be displayed in
a folder window, but I don't know what the list of 'everything'
includes, or the registry keys that would have to be modified to
include all the possible things. Being able to right click in the
white space of the background of an open explorer window and get a
'Open Command Window Here' context menu item would solve the whole
problem even for empty folders, and not clutter the context menu lists
for all the things that can be displayed in a folder window.
Maybe you could track down the key under
HKCR\.zip and add it to HKCR\*

In general,
an item can be added to any file extension menu
(and folders), by adding the necessary settings
under
HKCR\.ext\shell
OR
HKCR\classname\shell (where classsname is the file type.)

That's if the job can be done with just Registry
settings. (Ex.: Open with Notepad)

Context menu handlers are often used by
programs like ZIP programs and AV, in order to
add an item under the first menu divider on
the context menu. Those are created in the
Registry under
HKCR\.ext\shellex
OR
HKCR\classname\shell

They run a component when the menu item is
clicked.

If you don't find what you need under HKCR\.zip
look under the file type key (classname), like HKCR\zipfile.
The name of that key is the default value under
HKCR\.zip

Clicking in the folder window itself is really a
click on the system ListView window that's used
to display folder content. You'd have to hook that
somehow to get notification of the click. I'm not
sure that can even be done in a shell extension.
The ListView can be accessed via Windows messages
as a normal ListView, since the ListView's handle
is available, but it's running in a separate process,
So I imagine a system-wide hook would be needed
to catch the event messages like click or mouse-up.

The old folder.htt file has an embedded FileList
object that was actually a wrapper control
(a ShellFolderView) around the ListView. But even
that only provided a subset of functions for use
by Explorer, like the SelectionChanged event.

I wrote an Explorer Bar recently that might be
usable if you can script the operation. It's probably
not what you really want, but it does return the
customizing abilities of folder.htt to WinXP folder
windows. I wrote it with the thought that I might
have to use Windows Xtra Problems one of these
days and one of the biggest problems, from my
personal point of view, is that I'd have to give up my
numerous Win9x folder window customizations
(provided via folder.htt) for a "common tasks bar" that's
all but useless.

So I wrote an Explorer Bar that provides basic file
info. - thumbnails, file size, etc. But it also has "tabs".
The second tab is for JPG info. The 3rd tab show
an ADS file view of the folder. The 4th tab is a custom
webpage, which can be coded to do whatever you
want, thereby getting back all the options that Win9x/2000
for adding functionality in the HTML of a folder view. I use
it to bring my custom Win98 functions into WinXP folder
windows. It's all self- explanatory to someone familiar with
scripting.

www.jsware.net/jsware/jsfv.php3
Paul Randall
2008-06-06 23:08:19 UTC
Permalink
Post by mayayana
Post by Paul Randall
I suppose one solution would be to attach the 'Open Command Window
Here' item to the context menus of everything that can be displayed in
a folder window, but I don't know what the list of 'everything'
includes, or the registry keys that would have to be modified to
include all the possible things. Being able to right click in the
white space of the background of an open explorer window and get a
'Open Command Window Here' context menu item would solve the whole
problem even for empty folders, and not clutter the context menu lists
for all the things that can be displayed in a folder window.
Maybe you could track down the key under
HKCR\.zip and add it to HKCR\*
In general,
an item can be added to any file extension menu
(and folders), by adding the necessary settings
under
HKCR\.ext\shell
OR
HKCR\classname\shell (where classsname is the file type.)
That's if the job can be done with just Registry
settings. (Ex.: Open with Notepad)
Context menu handlers are often used by
programs like ZIP programs and AV, in order to
add an item under the first menu divider on
the context menu. Those are created in the
Registry under
HKCR\.ext\shellex
OR
HKCR\classname\shell
They run a component when the menu item is
clicked.
If you don't find what you need under HKCR\.zip
look under the file type key (classname), like HKCR\zipfile.
The name of that key is the default value under
HKCR\.zip
Clicking in the folder window itself is really a
click on the system ListView window that's used
to display folder content. You'd have to hook that
somehow to get notification of the click. I'm not
sure that can even be done in a shell extension.
The ListView can be accessed via Windows messages
as a normal ListView, since the ListView's handle
is available, but it's running in a separate process,
So I imagine a system-wide hook would be needed
to catch the event messages like click or mouse-up.
The old folder.htt file has an embedded FileList
object that was actually a wrapper control
(a ShellFolderView) around the ListView. But even
that only provided a subset of functions for use
by Explorer, like the SelectionChanged event.
I wrote an Explorer Bar recently that might be
usable if you can script the operation. It's probably
not what you really want, but it does return the
customizing abilities of folder.htt to WinXP folder
windows. I wrote it with the thought that I might
have to use Windows Xtra Problems one of these
days and one of the biggest problems, from my
personal point of view, is that I'd have to give up my
numerous Win9x folder window customizations
(provided via folder.htt) for a "common tasks bar" that's
all but useless.
So I wrote an Explorer Bar that provides basic file
info. - thumbnails, file size, etc. But it also has "tabs".
The second tab is for JPG info. The 3rd tab show
an ADS file view of the folder. The 4th tab is a custom
webpage, which can be coded to do whatever you
want, thereby getting back all the options that Win9x/2000
for adding functionality in the HTML of a folder view. I use
it to bring my custom Win98 functions into WinXP folder
windows. It's all self- explanatory to someone familiar with
scripting.
www.jsware.net/jsware/jsfv.php3
Thanks for the info and the link. I will play with it.

-Paul Randall
Paul Randall
2008-06-06 23:07:16 UTC
Permalink
http://www.microsoft.com/windowsxp/downloads/powertoys/xppowertoys.mspx
Post by Paul Randall
Post by Mark Pryor
http://download.microsoft.com/download/whistler/Install/2/WXP/EN-US/CmdHerePowertoySetup.exe
Hi, Mark
Thanks for the link. I just assummed that M$ had not added a
modifed CmdHerePowerToy. I have now checked and verified that the
current power toy is the same old one which doesn't do what I want.
I personally think they should have called it 'open command window
THERE', because HERE would be navigated to the currently open
window's path and THERE would be navigated to the folder being
pointed at.
After I have displayed a folder window, I often want to open a
command prompt window and navigate it to that same folder. I want a
file system folder window and a command prompt window, both opened
to the same folder path. If the folder is empty or there are no
folder-like items in the window, then there is no right-clickable
item that has the 'Open Command Window Here' menu item. If I
navigate up one folder level, I can then right click the icon of the
folder I just got out of, and choose 'Open Command Window Here'
which opens the command window to the place I wanted, but then I
also have to navigate my explorer folder window back to its original
location if I want to see something there while working in the
command window. That is way to much navigating to get a command
window navigated to the same folder as the original open folder
window.
If the explorer window I have open includes a .zip file, which kind
of looks like a folder, then its 'Open Command Window Here' menu
item does exactly what I want, because a command window can't 'ChDir
xxx,zip' to a zip-virtual-folder window, and the command window
defaults to the folder in which the zip file resides.
I suppose one solution would be to attach the 'Open Command Window
Here' item to the context menus of everything that can be displayed
in a folder window, but I don't know what the list of 'everything'
includes, or the registry keys that would have to be modified to
include all the possible things. Being able to right click in the
white space of the background of an open explorer window and get a
'Open Command Window Here' context menu item would solve the whole
problem even for empty folders, and not clutter the context menu
lists for all the things that can be displayed in a folder window.
Update:
I thought my old 'Open Command Window Here' came as a Power Toy, but I
don't know its vintage.

My old command prompt here registry entry:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Folder\shell\Command Prompt]
@="Open Command Prompt In Folder"

[HKEY_CLASSES_ROOT\Folder\shell\Command Prompt\Command]
@="cmd.exe /k pushd %L"

New Power Toy downloaded June 6, 2008 registry entry:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\shell\cmd]
@="Open Command Window Here"

[HKEY_CLASSES_ROOT\Directory\shell\cmd\command]
@="cmd.exe /k \"cd %L\""

I think the main difference is that my old menu item uses pushd %L to
navigatge to the path of the folder icon that was right clicked, while
the new power toy uses \"cd %L\" to do the same thing. My old one
shows up as a context menu entry for .ZIP files, but the new power toy
does not show up for .Zip files.

-Paul Randall
Stefan Kanthak
2008-06-07 15:36:39 UTC
Permalink
"Paul Randall" <***@cableone.net> wrote:

PLEASE stop those full quotes!
Post by Paul Randall
I thought my old 'Open Command Window Here' came as a Power Toy, but I
don't know its vintage.
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Folder\shell\Command Prompt]
~~~~~~
Post by Paul Randall
@="Open Command Prompt In Folder"
[HKEY_CLASSES_ROOT\Folder\shell\Command Prompt\Command]
~~~~~~
Post by Paul Randall
@="cmd.exe /k pushd %L"
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Directory\shell\cmd]
@="Open Command Window Here"
[HKEY_CLASSES_ROOT\Directory\shell\cmd\command]
@="cmd.exe /k \"cd %L\""
I think the main difference is that my old menu item uses pushd %L to
navigatge to the path of the folder icon that was right clicked, while
the new power toy uses \"cd %L\" to do the same thing. My old one
shows up as a context menu entry for .ZIP files, but the new power toy
does not show up for .Zip files.
I've underlined the culprit. Use it together with the information I
already gave in my previous post.
Regarding "PushD": try to use the version from the power toys on a
folder you opened with \\server\share\folder (see MSKB 317379 and 156276).

And while you're there: depending on your windows version and it's
security settings the simple "cmd.exe" might run a rogue binary an
attacker has placed in the directory/drive you just want to use your
power toy.
It's better to use the version with REG_EXPAND_SZ and %COMSPEC% I
incorporated in http://home.arcor.de/skanthak/download/EXTRA-2K.INF
to create all these registry entries.

Stefan

Continue reading on narkive:
Loading...