Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - Add context menu item for background of open folder window?

Reply
 
Old 06-05-2008   #1 (permalink)
Paul Randall


 
 

Add context menu item for background of open folder window?

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



My System SpecsSystem Spec
Old 06-05-2008   #2 (permalink)
Stefan Kanthak


 
 

Re: Add context menu item for background of open folder window?

"Paul Randall" <paulr901@xxxxxx> wrote:
Quote:

> 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.
Quote:

> 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

My System SpecsSystem Spec
Old 06-05-2008   #3 (permalink)
Paul Randall


 
 

Re: Add context menu item for background of open folder window?

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/libr...67(VS.85).aspx, I'm
thinking a WSC would not work.

-Paul Randall
My System SpecsSystem Spec
Old 06-06-2008   #4 (permalink)
Mark Pryor


 
 

Re: Add context menu item for background of open folder window?

My System SpecsSystem Spec
Old 06-06-2008   #5 (permalink)
Paul Randall


 
 

Re: Add context menu item for background of open folder window?

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
My System SpecsSystem Spec
Old 06-06-2008   #6 (permalink)
mayayana


 
 

Re: Add context menu item for background of open folder window?

> I suppose one solution would be to attach the 'Open Command Window
Quote:

> 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


My System SpecsSystem Spec
Old 06-06-2008   #7 (permalink)
Paul Randall


 
 

Re: Add context menu item for background of open folder window?

http://www.microsoft.com/windowsxp/d...powertoys.mspx

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
My System SpecsSystem Spec
Old 06-06-2008   #8 (permalink)
Paul Randall


 
 

Re: Add context menu item for background of open folder window?

Thanks for the info and the link. I will play with it.

-Paul Randall
My System SpecsSystem Spec
Old 06-07-2008   #9 (permalink)
Stefan Kanthak


 
 

Re: Add context menu item for background of open folder window?

"Paul Randall" <paulr901@xxxxxx> wrote:

PLEASE stop those full quotes!

Quote:

> 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]
~~~~~~
Quote:

> @="Open Command Prompt In Folder"
>
> [HKEY_CLASSES_ROOT\Folder\shell\Command Prompt\Command]
~~~~~~
Quote:

> @="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.
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

My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Search Context Menu Item - Restore After Vista SP1 Tutorials
'Run as administrator' Context Menu Item Vista General
New Context Menu Item - Restore or Remove Tutorials
Context Menu Item Vista General
Context menu item problem in Vista Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46