Simple Windows Registry Edits

Edit any file from Explorer

The simple way to add or modify configuration features in all modern versions of Windows (95+ and NT+) is to double-click on a .reg file. This, or the command

regedit /s filename.reg

will merge the contents of the file into the registry. For example, you can use the following text as a file, say edit.reg:

Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\*\shell]
[HKEY_CLASSES_ROOT\*\shell\Edit with WordPad\command]
@="\"%SystemDrive%\\Program Files\\Windows NT\\Accessories\\wordpad.exe\" \"%1\""

to add the entry "Edit with WordPad" to the list displayed when you right click on a file in Explorer. WordPad is a good choice as it displays UNIX-style text files correctly. Beware though, as WordPad silently modifies them to DOS-style: LF->CR,LF. WordPad will also not go to a specified line number; Notepad will do so unless it is in Format->Word Wrap mode. Note that in some older versions of Windows the WordPad file is called WRITE.EXE.

The HKEY_CLASSES_ROOT\*\shell key allows you to add any number of generic commands that can be applied to all files.

Create a command shell in any directory

Another useful entry gives you the option of opening a command prompt with the current directory set  into a directory by right clicking on the directory in Explorer:

Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\shell\Command Prompt]
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\shell\Command Prompt\command]
@="%SystemRoot%\\system32\\cmd.exe /F:ON /K cd %1"

Searching within files in Windows XP

A new issue with Windows XP is the behaviour of the Search for word in files feature. This does not search inside unrecognised file types. Thus, by default, .txt files are searched, but .java ones are not. The vital key is HKEY_CLASSES_ROOT\.ext\PersistentHandler for extension .ext and it needs to be set to the CLSID of the Plain Text persistent handler. You can find this by looking at the value for the .txt extension. On my system, merging the .reg file

Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\.java\PersistentHandler]
@="{5e941d80-bf96-11cd-b579-08002b30bfeb}"
for example, makes .java files searchable. You have to log off and back on to activate the change.

Editing the registry

An easy way to create these .reg files is to run REGEDIT, select the key subtree you want, and then File->Export it. You can then further edit the .reg file; it is a simple text file. Prior to Windows XP, there were two different registry editors. REGEDIT was the best for most purposes, but could not set up multistring values. These are needed, for example, when setting up environment strings for use with SVRANY.  You had to use REGEDT32 for these multistring values. REGEDIT will do multistring values in Windows XP and you can forget about REGEDT32, it calls REGEDIT.

Setting up a command-line based package and Icons

For command-line based packages such as NetPBM or the Sun JDK, I normally insert two shortcuts into the Start menu. One activates the package with the right path and directory:

	Command shell: 
		Target: %SystemRoot%\system32\cmd.exe /K "PATH=%ProgramFiles%\netpbm\bin;%PATH%" 
		Start in: "%HOMEDRIVE%%HOMEPATH%\My Documents\My Pictures"

and the other starts up an HTML help system:

	Help File: 
		Target: "%ProgramFiles%\netpbm\man\html\index.html" 
		Start in: "%ProgramFiles%\netpbm\man\html"

You will probably also want to give these shortcuts a custom Icon. The easy way is to use the Image Editor from the Microsoft Platform SDK, which you can download from Microsoft. Run Start->Microsoft Platform SDK->Tools->Image Editor and cut and paste an appropriate image into a new icon, save it as a .ico file, and select it from the Properties menu of your shortcut.


dan@ecs.soton.ac.uk