Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

problem

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.

registry

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.

question

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

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

share|improve this question
    
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? –  AthomSfere Oct 1 '13 at 16:50
1  
@AthomSfere it's a Notepad++ icon! –  naxa 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. –  naxa 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
show 2 more comments

3 Answers 3

up vote 6 down vote accepted

Make a backup of the registry.

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

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.cmd

The only keys I have under there are:

REGEDIT4

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.cmd]

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.cmd\OpenWithList]

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.cmd\OpenWithProgids]
"cmdfile"=hex(0):
share|improve this answer
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.) –  naxa Oct 1 '13 at 17:09
    
Thanks for posting your registry keys/values/data, gives comparison and confidence! –  naxa Oct 1 '13 at 17:13
add comment

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!

share|improve this answer
    
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. –  naxa 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. –  AthomSfere Oct 1 '13 at 17:18
add comment

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 ===========

REGEDIT4

[HKEY_CLASSES_ROOT\.cmd]
@="cmdfile"

[HKEY_CLASSES_ROOT\.cmd\PersistentHandler]
@="{5e941d80-bf96-11cd-b579-08002b30bfeb}"

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

REGEDIT4

[HKEY_CLASSES_ROOT\cmdfile]
@="Windows Command Script"
"EditFlags"=hex:30,04,00,00
"FriendlyTypeName"=hex(2):40,25,53,79,73,74,65,6d,52,6f,6f,74,25,5c,53,79,73,\
  74,65,6d,33,32,5c,61,63,70,70,61,67,65,2e,64,6c,6c,2c,2d,36,30,30,33,00

[HKEY_CLASSES_ROOT\cmdfile\DefaultIcon]
@=hex(2):25,53,79,73,74,65,6d,52,6f,6f,74,25,5c,53,79,73,74,65,6d,33,32,5c,69,\
  6d,61,67,65,72,65,73,2e,64,6c,6c,2c,2d,36,38,00

[HKEY_CLASSES_ROOT\cmdfile\shell]

[HKEY_CLASSES_ROOT\cmdfile\shell\edit]

[HKEY_CLASSES_ROOT\cmdfile\shell\edit\command]
@=hex(2):25,53,79,73,74,65,6d,52,6f,6f,74,25,5c,53,79,73,74,65,6d,33,32,5c,4e,\
  4f,54,45,50,41,44,2e,45,58,45,20,25,31,00

[HKEY_CLASSES_ROOT\cmdfile\shell\open]
"EditFlags"=hex:00,00,00,00

[HKEY_CLASSES_ROOT\cmdfile\shell\open\command]
@="\"%1\" %*"

[HKEY_CLASSES_ROOT\cmdfile\shell\print]

[HKEY_CLASSES_ROOT\cmdfile\shell\print\command]
@=hex(2):25,53,79,73,74,65,6d,52,6f,6f,74,25,5c,53,79,73,74,65,6d,33,32,5c,4e,\
  4f,54,45,50,41,44,2e,45,58,45,20,2f,70,20,25,31,00

[HKEY_CLASSES_ROOT\cmdfile\shell\runas]
"HasLUAShield"=""

[HKEY_CLASSES_ROOT\cmdfile\shell\runas\command]
@=hex(2):25,53,79,73,74,65,6d,52,6f,6f,74,25,5c,53,79,73,74,65,6d,33,32,5c,63,\
  6d,64,2e,65,78,65,20,2f,43,20,22,25,31,22,20,25,2a,00

[HKEY_CLASSES_ROOT\cmdfile\shell\runasuser]
@="@shell32.dll,-50944"
"Extended"=""
"SuppressionPolicyEx"="{F211AA05-D4DF-4370-A2A0-9F19C09756A7}"

[HKEY_CLASSES_ROOT\cmdfile\shell\runasuser\command]
"DelegateExecute"="{ea72d00e-4960-42fa-ba92-7792a7944c1d}"

[HKEY_CLASSES_ROOT\cmdfile\ShellEx]

[HKEY_CLASSES_ROOT\cmdfile\ShellEx\ContextMenuHandlers]
@="Compatibility"

[HKEY_CLASSES_ROOT\cmdfile\ShellEx\ContextMenuHandlers\Compatibility]
@="{1d27f844-3a1f-4410-85ac-14651078412d}"

[HKEY_CLASSES_ROOT\cmdfile\ShellEx\DropHandler]
@="{86C86720-42A0-1069-A2E8-08002B30309D}"

[HKEY_CLASSES_ROOT\cmdfile\ShellEx\PropertySheetHandlers]

[HKEY_CLASSES_ROOT\cmdfile\ShellEx\PropertySheetHandlers\ShimLayer Property Page]
@="{513D916F-2A8E-4F51-AEAB-0CBC76FB1AF8}"

[HKEY_CLASSES_ROOT\cmdfile\ShellEx\{8895b1c6-b41f-4c1c-a562-0d564250836f}]
@="{1531d583-8375-4d3f-b5fb-d23bbd169f22}"
share|improve this answer
    
Thanks for the lovely editing example, naxa. Much clearer! –  Debra Oct 3 '13 at 0:57
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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