A. If you right click on a .bat or .cmd file and select edit the file will be opened in Notepad however you may want to use a different editor as the default.

This can be accomplished by making two small registry modifications

  1. Start the registry editor (regedit.exe)
  2. We will first change the editor used for .bat files.
  3. Move to HKEY_CLASSES_ROOT\batfile\shell\edit\command
  4. Double click on the (Default) value and change to the executable you want to use to edit the batch files, e.g. C:\Program Files\DevStudio\SharedIDE\BIN\msdev.exe "%1" if you wanted to use Microsoft Development editor. Click OK
  5. We shall now perform the same for .cmd files
  6. Move to HKEY_CLASSES_ROOT\cmdfile\shell\edit\command
  7. Double click on the (Default) value and again change to the editor to use. Click OK

No reboot is required and any changes take immediate effect

You could also perform the above via a GUI front end by selecting View - Folder options - File Types from Explorer. You could then select the file type, e.g. "MS-DOS Batch file" and click Edit. The context menu options available are listed and you can modify them. All this does is update the registry values we have looked at.

If you wanted to leave the existing option and add a new Edit option, e.g. "Edit with MSDEV" perform the following (in this example we will only update .bat with a second edit option but the same could be performed on cmd):

  1. Start the registry editor (regedit.exe)
  2. Move to HKEY_CLASSES_ROOT\batfile\shell
  3. From the Edit menu select New - Key and enter a name of "editms" (don't type the quotes)
  4. Double click on the (Default) value under editms and set the name to be displayed on the context menu, e.g. "Edit with MSDEV", click OK
  5. Select editms and select New - Key from the edit menu and enter a name of "command" (again don't enter the quotes)
  6. Double click the (Default) under command and set to the required value, e.g. C:\Program Files\DevStudio\SharedIDE\BIN\msdev.exe "%1" for msdev. Click OK
  7. Close the registry editor

You will now have two options when you right click on a batch file, edit and edit with MSDEV.

Click here to view image

You can use this on any type of file, e.g. txt files by editing HKEY_CLASSES_ROOT\txtfile\shell\open\command. Just look through HKEY_CLASSES_ROOT\xxxfile where xxx is the extension (actually to find the correct file type use the assoc command, e.g. assoc .txt, it will then return the file type, txtfile).