Configuring Windows Explorer
Suggested Modifications to the Context Sensitive Menus

Intro | Open a DOS Shell | Create a Directory | Print a Directory | Copy Path To Clipboard | PKUnzip | BAT Files | HTML | Protect the Registry | vbs (virus) Protection | Unregistered File Types | All File Types | Notepad | DOS Edit


In Windows Explorer, a customizable context sensitive menu is displayed when you right click either a folder or a file. Basically, there are 5 types of modifications
  1. Add a new entry
  2. Modify an existing entry
  3. Specify the default entry
  4. Re-name an entry
  5. Remove an entry
Normally, users make these modifications via the View/Options.../File Types dialog box and its associated Edit File Types dialog box. (Except that re-naming an entry always requires editing the registry.) By associating EditFlags with a specific file type, it is possible to keep users from making one or more of these modifications.

Open a DOS Shell

Add a way to open a DOS Shell in the selected directory
Edit Folder via View/Options.../File Types
Add new DOS Shell action
For Windows 95 c:\windows\ /k cd
For Windows NT 4 c:\winnt\system32\cmd.exe /k cd
Simply using c:\winnt\system32\cmd.exe will work in the directory tree, but not in the file pane when directory names contain spaces. c:\winnt\system32\cmd.exe /k cd "%1" also works because the double quotes allow directories to contain spaces. The /k tells the command interpreter to execute the DOS command following it, and to leave the window open at a command prompt when it is complete.

According to theory, it should be possible to make portable code by using %comspec% instead of either c:\windows\ or c:\winnt\system32\cmd.exe. However, NT 4.0 won't accept it even though the Windows NT Diagnostics indicates that comspec = c:\winnt\system32\cmd.exe. The following was observed using NT 4.0, Service Pack 3.
c:\winnt\system32\cmd.exe /k cd Works
c:\winnt\system32\cmd1.exe /k cd Bad filename, will not save -
"The specified program could not be found"
c:\winnt\system3\cmd.exe /k cd Bad directory, saves but when selected
"Windows cannot find cmd.exe"
%comspec% /k cd Will not save -
"The specified program could not be found"
%comspec%\cmd.exe /k cd Saves but when selected
"Cannot find the file [directory name]"
%comspec% /k cd %1 Placing this directly in the registry fails -
"Cannot find the file [directory name]"

I always want doskey to automatically run when I'm at a DOS prompt. One suggested way to accomplish that is to edit the pif file associated with In the field labeled Batch file, simply enter doskey.

In Windows 98 (not sure about other versions), that works ... sort of. However, I also like to close DOS windows by clicking the x in the upper righthand corner of the title bar. Unfortunately, the pif-file modification also causes a new "are you sure" message to appear.

Therefore, a better way to do this is to add doskey to autoexec.bat.

Create a Directory

Add a way to Create a directory by right clicking on a directory name
Edit Folder via View/Options.../File Types
Add new Make Directory action
For Windows 95 c:\windows\ /c cd "%1" | md NewDirectory
For Windows NT 4 c:\winnt\system32\cmd.exe /c cd "%1" | md NewDirectory
(not tested)

Normally, you have to

This modification allows the simpler and more intuitive
A DDE call to explorer would probably work better (i.e. not show a DOS screen), but there is no documentation.

Simply using c:\windows\ /c md NewDirectory only works in the directory tree, but not in the file pane.

I have written a program which simplifies this even more. When added to the context menu, this program produces a dialog box. See here for more information.

Print a Directory

Add menu selections to print a selected directory and to save it to a text file
Edit Folder via View/Options.../File Types
Add new Make dir.txt action
For Windows 95 c:\windows\ /c dir /a/ogen/-p "%1"> "%1"\dir.txt
For Windows NT 4 c:\winnt\system32\cmd.exe /c dir /a/ogen/-p "%1"> "%1"\dir.txt
Add new Print DIR action (pick one)
c:\windows\ /c dir /a/ogen/-p "%1"> lpt1:
c:\winnt\system32\cmd.exe /c dir /a/ogen/-p "%1"> ~dir.txt & notepad.exe /p ~dir.txt & del ~dir.txt &
c:\winnt\system32\cmd.exe /c dir /a/ogen/-p "%1"> lpt1: does not work on my LAN system

The /c tells the command interpreter to execute the DOS command following it, and to close the window when it completes.

There are many possible variations of the dir command.

The & is used in NT 4.0 to separate several commands on the same command line. If the final & is left off, and "%1" is not used in the command string, then the name of the directory is appended to the last command and this causes an error. The & does not work on Windows 95.

The "%1" is needed to make the commands work in the file (right hand) side of the Explorer window. The double quotes allow paths to contain spaces.

I tried using %temp%\ to keep from creating temporary files in a working directory, but the actual directory name (c:\temp\) was substituted when the data was saved in the registry (NT 4.0). So much for portable code.

Copy Path To Clipboard

Add a way to copy a directory path to the Windows clipboard by right clicking on a directory name
Edit Folder via View/Options.../File Types
Add new Copy Path To Clipboard action
C:\Utils\CopyToClipboard.exe "%1"

In order to right click a file and place its fully qualified path in the clipboard, add new Copy Path To Clipboard shortcut to the SendTo menu. Set the Target to
Using this produces only a DOS path - typical 8.3 with tildes and no spaces. When the same executable is called via the registry, long names are used. (Great OS :)

For a way to modify the registry so that long filenames are used for all files, see the discussion on providing menu selections for all files below.

You will need to download CopyToClipboard.exe (14 kb)

You may use it freely as long as I get credit. The source code and discussion are here.


Create an association to UnZip a file and/or to view its contents.
This assumes that pkz204g is installed in C:\PK204G

Add a new ZIP filetype via View/Options.../File Types
Add new Un-Zip action C:\PK204G\Pkunzip.exe -d
The -d causes the stored directory structure to be preserved.
Add new View Contents action
c:\winnt\system32\cmd.exe /k "C:\PK204G\Pkunzip.exe -vb %1 |more"
The double quotes are required because the DOS command contains spaces between the parameters. However, this will not work with directories which contain spaces.

BAT Files

Change the BAT file default from Execute to Edit
The default action for BAT files is Open which actually executes the file. This is very confusing since in NotePad, Open reads a file for editing. Allowing Open to be a synonym for Execute is user hostile at best. In addition, BAT files have EditFlags set so that a casual user can not modify the default behavior.

In the registry, the default value for .bat is batfile. Locate batfile, disable the EditFlags, re-name Open as Execute, re-name Edit as Edit in Notepad, and change the default to Edit in Notepad.

There is a small problem with this modification - shortcuts to batch files perform the default action ... and, of course, everything in the Start menu is a shortcut. This is probably why users are not normally allowed to change the BAT default action. Simply renaming the default action has no affect on this.


Modifications to the htm & html associations
As with many applications, the use of the term Open is ambiguous. For instance, a user may want to open an HTML document in Netscape, MS Internet Explorer, MS Front Page, Notepad, Hot Dog, MS Word, or one of about 100 other common HTML editors. Obviously, the use of explicit action names can be used to reduce user confusion. It is strongly suggested that you use words like Edit or Browse, and that you identify the program and its version. This helps if you run several versions of popular browsers to test pages.

In the registry
Rename Open to something that makes sense, like Browse in IE 3.0

Using Internet Document (HTML) via View/Options.../File Types
Add a new Edit in Notepad action C:\WINNT\system32\NOTEPAD.EXE
Change the default to your choice. Though most developers prefer an editor to a browser, some applications, such as FrontPage and MSNBC News Alert, will fail to display a page in a viewer if an editor is the default.

Protect the Registry

Protect the Registry by changing the default action for *.reg files
The default action when you double click a *.reg file is to merge the contents of that file with the registry!

When an application is installed, it makes most of the necessary registry modifications by merging an associated *.reg file. Frequently, these files are left on the disk after the installation is complete. A quick search of my c-drive found 31 of these time bombs.

Using regedit, it is possible to export some, or all, of the registry as a text file with the extension .reg. These files can also be merged back into the registry. (Think backup!)

In one case, a friend had captured an reg file on a Windows 95 machine and was working with it on a Windows NT 4 machine. Yes, he accidentally double clicked the file, the Windows 95 registry was written over the NT registry, and the machine crashed. He had to reload NT.

To fix this, locate Registration Entries via View/Options.../File Types and change the default from Merge to Edit.

Warning: This modification may cause some applications to install incorrectly. Any application which relies on the default action for *.reg files will open notepad instead of modifying the registry. If this occurs, it is my suggestion that you abort the installation, temporarily change the default action back to Merge, and re-attempt the install.

vbs (virus) Protection

Protect your system from vbs (Visual Basic Script) viruses by changing the default action for *.vbs files
The default action when you double click a *.vbs file is to execute it. Well, these are programs, so it makes sense to execute them, right? Well, on May 4, 2000, the ILOVEYOU vbs trojan/virus was sent around the world as an email attachment named Love-Letter-For-You.txt.vbs. Unfortunately, most users have display file extension disabled (the Microsoft braindead default) and the attachment was displayed as Love-Letter-For-You.txt. Since everyone knows that text files can not contain viruses, this thing was opened, extreme damage was done to hundreds of thousands of machines, and it emailed itself to everyone in the available address book(s).

Well, obviously, VB Script is not an important part of anyone's system (my Windows 95 system does not even have it installed). Its entire purpose seems to be to let viruses be included with data files (Word documents, Excell spreadsheets, html pages). Therefore, I suggest the following precautions.

These simple precautions should help protect you from this class of viruses, and you probably won't miss the ability to execute these "imbedded datafile programs".

It seems that Microsoft wants VBS to replace bat files. If so, then this fix could cause a problem.

Unregistered File Types

Add an Open in NotePad menu selection for all unregistered file types
Using RegEdit, locate HKCR/Unknown. Notice that the default value is not set. This is why these values can not be edited via the Explorer dialog boxes. Also notice that the key shell/openas/command already exits. This provides the default Open As... menu selection and associated dialog box when you right click or double click files with un-registered (i.e. unknown) extensions.

Even though we have already associated NotePad with all file types by placing a link to it in the Send To menu (directory), I strongly recommend the following modifications.

Right click on HKCR/Unknown/shell and select New/Key. Name the key notepad. Right click on notepad and add a command key. Set the defaults as follows
HKCR/Unknown/shell notepad
HKCR/Unknown/shell/notepad Open in Notepad
HKCR/Unknown/shell/notepad/command C:\WINDOWS\NOTEPAD.EXE %1
Now, when you right click any file with an unknown (un-registered) file type, Open in NotePad will show in the context sensitive menu. Since the shell default is set to notepad, double clicking any unknown file will also open NotePad.

This modification also affects many registered file extensions, such as DLL (Application Extension), PRT (Microsoft Schedule+ Print), and ICO (Icon) because, even though they are registered, they do not have shell keys.

Also, I find it useful to change the File Type to Not Registered. This makes sorting by the type even less useful than it already is, but it also lets me know that double clicking the file will open notepad. This is done by changing the default value of HKCR/Unknown to Not Registered.

All File Types

Add menu selections for all file types
Modifications made to HKCR/*/shell/xxx/command will appear for all file types and will be shown first in the context sensitive menu. For instance, you can add an Open in NotePad selection (similar to that in the previous section) to HKCR/*/shell/notepad/command. Change the default names from Open in Notepad to Open in Notepad (*) or Open in Notepad (Unknown) to observe how it all works.

Warning: Adding HKCR/*/shell/notepad/command will cause the MS Office 95 toolbar to fail. Specifically, with the changes suggested above, all of the buttons on the MS Office toolbar open notepad! The shortcuts in the Start Menu work just fine, as do the shortcuts on the Desktop. Even double clicking a file in Windows Explorer still works. Just the toolbar is broken. It appears that single clicking a toolbar icon runs the first selection in the context sensitive menu (which is always an action from HKCR/*/shell/[verb] if it exists). However, you can right click and explicitly select the default.

Personally, I have decided that the value of allowing the Copy Path to Clipboard function for all files far out weighs the value of the MS Office toolbar. Especially, since the SendTo technique only copies short, truncated, almost impossible to use 8.3 filenames and paths, and placing the same command in the registry generates full length names. As a result, I have deleted the toolbar and installed Notepad, DOS Edit, and Copy Path to Clipboard to HKCR/*. (In some cases, Copy Path to Clipboard may produce 8.3 file and directory names. If that happens, try "%L" instead of "%1".)

By the way, if you hold down the Shift key when you right click a file, all the Unknown shell commands will be displayed in the menu. Thus, this is another way to add menu selections to all files :)

*.pif and *.url files do not show the menus defined for all file types. This appears to be partially connected to the IsShortcut registry value. If this parameter is removed (renamed), the menus selections show up for *.url files, but *.lnk files, which have the same parameter, always show the selections.

If you want the options associated with * to show up in View/Options.../File Types, then under HKCR/* add a binary value called EditFlags and set the value to 12 00 00 00 (hex). (02 00 00 00 actually does the job - it normally says that the MIME value can not be edited. I have no clue why this works. The extra bit is just for safety, it disables the Remove button.)


Add a Notepad menu selection for all folders
Edit Folder via View/Options.../File Types

Add new Notepad action with a command of notepad.exe.

This creates a notepad.exe %1 entry in the registry. (The %1 does not show in the Edit Action dialog box.) Now, edit the registry to remove the "%1".

This menu option allows you to right click on any directory and open notepad with an empty document. Then when you save your work, the default directory is the one you were pointing to. Thus, it is no longer necessary to hunt for a directory in the SaveAs dialog box.

This same enhancement can be used for other applications such as MS Word, html editors, and the like.

This does not work in Windows 98! It does not matter which directory you are pointing to, the Notepad default directory is My Documents (no new release is complete until something useful is broken).

DOS Edit

Alright, you already have various links to Notepad, so why do you want a link to the old DOS text editor, Simple, any text file produced in unix uses a different end-of-line terminator than what Notepad uses. As a result, if you open an html file with a unix type format in Notepad, the file does not format correctly and there are little square boxes everywhere. However, open the same file in and it is displayed with the line breaks in the correct locations, as you would expect. In addition, if you save the file from, all the line terminations are converted to the DOS standard used by Notepad.

The other reason that I use is to print files which wrap funny in Notepad because some lines contain too many characters. (The default font size and page margins in Notepad are too large to print 80 characters on a line.)

Unfortunately, when your printer is located on a LAN, if you simply add a link to to the context menu, you won't be able to print. (Some companies will do anything to kill DOS! :)

Fortunately, a simple solution is available (but it took months to figure out).

Create a shortcut to in the SendTo directory. Windows will automatically detect that this is a 16-bit DOS program and save the shortcut as a PIF file. (The extension is hidden in Windows Explorer, but visible using dir from a DOS prompt.)

Then, in the registry, any time you want to access Edit, simply call the PIF file.

Now you can print! :)

BTW, you could link to C:\Windows\Command\Edit.pif instead of creating a new copy in the SendTo directory. If this does not exist on your system, the run once and windows should automatically create it.

Unfortunately, even with this hack, you still can not print from if it is opened from within WS_FTP95 (my usual link to unix files).

This print problem does not exist under Windows NT 4.0. Simply link to However, you must execute the following command to capture the printer port.

   net use lpt1: \\server\printer /presistent:yes
Windows 95 allows you to capture lpt1 via the control panel.

Under 95, the user can select the printer port.
Under NT, prints to lpt1 only. Out of memory with 482K file, but notepad can read it.

Author: Robert Clemenzi -
URL: http:// / user / clemenzi / technical / WinExplorer / WinExplorerMenus.htm