If I run a .cmd file from cmd.exe it works fine. However if I run it from Start menu / Run line, it opens in Notepad++, my editor. (edit I've it installed for years, didn't update it recently. However, this phenomenon with the .cmds only started recently.)

Both time, I use a full absolute path. I use windows 7 x64.


My HKLM/Software/Classes/cmdfile/shell/open/command's (Default) is set to "%1" %* and .cmd's (Default) is cmdfile in both HKLM and HKCU and there is no cmdfile in HKCU.

However the other keys I did not check / did not understand their meaning or significance, in particular I don't know an easy way to follow clsid values, and know what do they mean as a given key.

context menu

If I right click a .cmd the bold text is its name (edit) says "Open". But even from here if I click open, it opens in notepad++, my text editor.

icon (edited) If I go to the folder in explorer, the icon is a Notepad++ icon.


Why is the Run line behaving differently from the command line?

How can I restore my .cmds to run from the Run dialog, too?

  • Something is out-of-whack for sure. If you right-click a .CMD then by default the highlighted action should be "Open", not the name of the .CMD. Also Notepad++ doesn't appear to associate to .CMD file by default. – Ƭᴇcʜιᴇ007 Oct 1 '13 at 16:50
  • If you navigate to the path of the cmd file, in explorer do you see the batch icon or a notepad icon? – Austin T French Oct 1 '13 at 16:50
  • 1
    @AthomSfere it's a Notepad++ icon! – n611x007 Oct 1 '13 at 16:51
  • @techie007 sorry I realize the bold name was due me right-clicking it in Total commander. I did it in explorer and there it's 'open'. But the behavior is still wrong. Edited the q. – n611x007 Oct 1 '13 at 16:57
  • 1
    Under HKLM/Software/Classes/.cmd/PersistentHandler there should be a GUID as the (Default). For exmaple: {5e941d80-bf96-11cd-b579-08002b30bfeb}. Search the registry further for that GUID and it should (eventually) lead to you to HKLM\SOFTWARE\Classes\CLSID\{5e941d80-bf96-11cd-b579-08002b30bfeb} (again the GUID is an example, might not be the same on yours), which should have a default value of "Plain Text persistent handler". Is that the case for you? If this just started happening, have you tried a System Restore back to a point when it was working as expected? – Ƭᴇcʜιᴇ007 Oct 1 '13 at 17:02

Make a backup of the registry.

After that you should delete any values with "Notepad++" under the following key:


The only keys I have under there are:




  • 1
    You were right! I had HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.cmd\UserChoice (note UserChoice) key which contained Progid="Applications\notepad++.exe"! I've deleted these and it works. (Also had values in OpenWithList! They can go to.) – n611x007 Oct 1 '13 at 17:09
  • Thanks for posting your registry keys/values/data, gives comparison and confidence! – n611x007 Oct 1 '13 at 17:13

It sounds like you have somehow changed your default file association for .cmd files.

Navigate to any .cmd file:

  • Right Click and select properties
  • Where you see "Opens With" -> Click
  • Navigate to %Systemroot%\System32\
  • Choose cmd.exe

Your default association should now be fixed!

  • On Windows 7, when I right click or pick the properties of a .CMD file, I'm not offered "Open With". You sure that works on your system? – Ƭᴇcʜιᴇ007 Oct 1 '13 at 16:58
  • 1
    I can confirm @techie007 , I see no "Open With" in cmd file's Properties dialog, neither as a button on any immediate tab, nor as a tab. Also not in the context menu, nor with shift+right clicking the file. – n611x007 Oct 1 '13 at 17:03
  • 1
    @techie007 Well, no it doesn't. I should have known better too! Generic advice is not always right, I should have double checked it too. – Austin T French Oct 1 '13 at 17:18

In Windows 7, if you aren't up to editing the registry, it's Start > Control Panel > Default Programs > Associate a filetype or protocol with a particular program. (Often takes a long time to load!) ".cmd" should be associated with "Windows Command Script". Since it's obviously not, click Change Program, Browse to \windows\system32\cmd.exe and select it, checkmark the box for "always use", and that should fix the association.

Or you can do it directly in the registry, but the location will be under HKEY_CLASSES_ROOT, where file associations are set. CMD files are by default associated with the "plain text persistent handler". Default is:

======= for the .CMD extension ===========




====== for CMDFILE type ==============


@="Windows Command Script"






@="\"%1\" %*"












[HKEY_CLASSES_ROOT\cmdfile\ShellEx\PropertySheetHandlers\ShimLayer Property Page]

  • Thanks for the lovely editing example, naxa. Much clearer! – Debra Oct 3 '13 at 0:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.