For Windows 95 | c:\windows\command.com /k cd | |
For Windows NT 4 | c:\winnt\system32\cmd.exe /k cd |
According to theory, it should be possible to make portable code by using %comspec% instead of either c:\windows\command.com 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 command.com. 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.
For Windows 95 | c:\windows\command.com /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
Simply using c:\windows\command.com /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.
For Windows 95 | c:\windows\command.com /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 |
c:\windows\command.com /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 "%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.
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
C:\Utils\CopyToClipboard.exe |
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)
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. |
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.
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. |
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.
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.
It seems that Microsoft wants VBS to replace bat files. If so, then this fix could cause a problem.
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 |
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.
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 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
The other reason that I use Edit.com 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 Edit.com 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 Edit.com 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 Edit.com once and windows should automatically create it.
Unfortunately, even with this hack, you still can not print from Edit.com 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 edit.com However, you must execute the following command to capture the printer port.
net use lpt1: \\server\printer /presistent:yesWindows 95 allows you to capture lpt1 via the control panel.
Under 95, the user can select the printer port.
Under NT, edit.com prints to lpt1 only.
Out of memory with 482K file, but notepad can read it.