.cmd runs from cmd.exe but not from start menu / Run dialog

4

1

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?

n611x007

Posted 2013-10-01T16:44:56.963

Reputation: 5 291

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 – 2013-10-01T16:50:05.720

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 – 2013-10-01T16:50:21.960

1@AthomSfere it's a Notepad++ icon! – n611x007 – 2013-10-01T16:51:49.100

@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 – 2013-10-01T16:57:11.463

@techie007 I think definitely not N++: it does not associate like this (by default), I didn't do it willingly at least not from N++, and I use N++ for a long time and didn't do any updates recently. – n611x007 – 2013-10-01T16:58:37.750

1Under 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 – 2013-10-01T17:02:36.707

@techie007 exact same values as for you everywhere. did not try restore yet. – n611x007 – 2013-10-01T17:07:26.740

Answers

6

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):

Rik

Posted 2013-10-01T16:44:56.963

Reputation: 11 800

1You 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 – 2013-10-01T17:09:16.123

Thanks for posting your registry keys/values/data, gives comparison and confidence! – n611x007 – 2013-10-01T17:13:51.723

1

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!

Austin T French

Posted 2013-10-01T16:44:56.963

Reputation: 9 766

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 – 2013-10-01T16:58:03.060

1I 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 – 2013-10-01T17:03:18.817

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 – 2013-10-01T17:18:11.620

1

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}"

Debra

Posted 2013-10-01T16:44:56.963

Reputation: 4 000

Thanks for the lovely editing example, naxa. Much clearer! – Debra – 2013-10-03T00:57:16.597