102

Windows 7 Error: Is this command correct?

ShellExecute failed (2): Is this command correct? "C:\Program Files (x86)\Notepad++\notepad++.exe [location of file to edit]

I seem to have some issue with RIGHT CLICK > Edit with Notepad ++. This is on a fresh install of Microsoft Windows 7 Professional 64-Bit.

I can't seem to find any notice of this error? Or is this just some Windows 7 config issue?

Jeff F.
  • 4,443
Jakub
  • 3,181

11 Answers11

191

This is caused when you set Notepad++ to run as administrator on Windows 7.

Go into your registry as an administrator and search for notepad++.exe. Find the key under HKEY_CLASSES_ROOT that has an entry with the Edit with Notepad++ (or maybe Edit with &Notepad++) and delete the entire key. Right click and you should see that you no longer have that option.

Now we re-create it:

  1. Go to:

    HKEY_CLASSES_ROOT\*\shell
    
  2. Create a new key under shell called OpenWithNotepad and create a subkey under that called command.

  3. In the OpenWithNotepad key the default string is what you want the context menu item to be called. I set it to Open with Notepad++.

  4. Still in the OpenWithNotepad key, create a new string value called icon and set the value to path-to-notepad++.exe where path-to-notepad++.exe should be the full path, e.g. C:\Program Files\Notepad++\notepad++.exe.

  5. Under the command key edit the default string value and change it to "path-to-notepad++.exe" "%1" where path-to-notepad++.exe should be the full path, e.g. C:\Program Files\Notepad++\notepad++.exe.

When you right click this option it should now ask you properly for giving Notepad++ admin access to a file.

You still need to go to the properties for notepad++.exe and set it to run as an administrator.

Steve
  • 1,911
57

This is a registry file that might help everybody:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\*\shell\OpenWithNotepad]
@="Edit with &Notepad++"
"icon"="C:\\Program Files (x86)\\Notepad++\\Notepad++.exe"

[HKEY_CLASSES_ROOT\*\shell\OpenWithNotepad\Command]
@="\"C:\\Program Files (x86)\\Notepad++\\Notepad++.exe\" \"%1\""

Copy it into Notepad and save it with a .reg extension. Close Notepad and double-click the file.

John Swaringen
  • 671
  • 5
  • 5
27

On my Windows 7 machine (32 bit) I set notepad++ to run as administrator, doing so caused the explorer shell extension to stop working with the "Shell Execute failed" error. Disabling this setting (right click, properties, compatibility...) resolved the issue. Maybe this is what is causing your problems? (Now all I need is an "Edit in Notepad++ as Administrator" shell extension....)

withakay
  • 441
15

I recently upgraded Notepad++ and I started getting this "ShellExecute failed" error when trying to use the "Edit in Notepad++" context menu feature.

While I found many reports of this error online, none of the solutions that I saw worked on my machine.

Here are the steps I used to resolve the problem:

  1. Right click on notepad++.exe in the Notepad++ program folder.
  2. Select the Properties menu item.
  3. Select the Compatibility tab.
  4. When “Run this program as an administrator” is enabled just for the current user, you can disable by clicking on the checkbox.
  5. Otherwise, "Run this program as an administrator” is enabled for all users and you have to click on “Change settings for all users” first, then you can disable the option.

I created an image for each of these scenarios and attached them below.

I highlighted "Run this program as an administrator” in both images and highlighted the “Change settings for all users” button in green for the scenario where the option was enabled for all users.

RunAsAdmin CurrentUser Scenario RunAsAdmin AllUsers Scenario

Jeff
  • 261
5

Uninstall, clean registry and re-installing didn't work for me. Neither was I running in a compatibility mode so that could not have been my issue.

What the issue was for me is that I checked the option "Run this program as an administrator" in the compatibility tab. I had turned this option on to be able to save e.g. the hosts file. After unchecking this I finally could rightclick and edit files using NotePad++ again.

Kana
  • 51
3

This adds to @John Swaringen's post above with the additional identifier for the Admin menu item. Before applying these changes it's important to ascertain that N++ is indeed installed at C:\Program Files (x86)\Notepad++. If not, then the correct install path will have to be substituted for it in the appropriate section of the following snippet(s).

On show are three files with links to them on the home drive- or copy the code to a text file with .reg extension:

The first is for the Admin menu item only:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT*\shell\OpenWithNotepad] @="Edit with &N++ [Admin]" "icon"="C:\Program Files (x86)\Notepad++\Notepad++.exe"

[HKEY_CLASSES_ROOT*\shell\OpenWithNotepad\Command] @=""C:\Program Files (x86)\Notepad++\Notepad++.exe" "%1"" [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID{B298D29A-A6ED-11DE-BA8C-A68E55D89593}\Settings] "ShowIcon"=dword:00000000

The second is for both items on the menu:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT*\shell\OpenWithNotepad] @="Edit with &N++ [Admin]" "icon"="C:\Program Files (x86)\Notepad++\Notepad++.exe"

[HKEY_CLASSES_ROOT*\shell\OpenWithNotepad\Command] @=""C:\Program Files (x86)\Notepad++\Notepad++.exe" "%1"" [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID{B298D29A-A6ED-11DE-BA8C-A68E55D89593}\Settings] "ShowIcon"=dword:00000001

The third is to remove the Admin item entirely:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT*\shell\OpenWithNotepad] "icon"=-

[HKEY_CLASSES_ROOT*\shell\OpenWithNotepad\Command] @=""

[-HKEY_CLASSES_ROOT*\shell\OpenWithNotepad\Command]

[-HKEY_CLASSES_ROOT*\shell\OpenWithNotepad]

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID{B298D29A-A6ED-11DE-BA8C-A68E55D89593}\Settings] "ShowIcon"=dword:00000001

Necro edit: For 64 bit N++ try the following:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT*\shell\OpenWithNotepad] @="Edit with &N++ [Admin]" "Icon"=hex(2):43,00,3A,00,5C,00,50,00,72,00,6F,00,67,00,72,00,61,00,6D,00,20,00,46,00,69,00,6C,00,65,00,73,00,5C,00,4E,00,6F,00,74,00,65,00,70,00,61,00,64,00,2B,00,2B,00,5C,00,4E,00,6F,00,74,00,65,00,70,00,61,00,64,00,2B,00,2B,00,2E,00,65,00,78,00,65,00,00,00

[HKEY_CLASSES_ROOT*\shell\OpenWithNotepad\Command] @=""C:\Program Files\Notepad++\Notepad++.exe" "%1"" [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID{B298D29A-A6ED-11DE-BA8C-A68E55D89593}\Settings] "ShowIcon"=dword:00000001

In W11 this only shows on the W10 classic right-click menu, for the W11 menu (without the N++ icon) see this answer.

1

I have Windows 7 64 Bit and I'm working with Notepad++ for more than a year on different Windows 7 64 Bit installation and I never seen such an error. Are you tried complete uninstall, run CCleaner, and installing Notepad++ again?

bman
  • 422
  • 2
  • 8
  • 16
1

in case you did not get it fixed yet, i had the same issue and tried all the above. I had told Notepad++ to start in compatibility mode and got that error. After i turned it off, everything went back to normal.

1

In my case thing that helped was to install Notepad++ in regular "Program Files" directory, not in "Program Files (x86)". Path is just messed up :)

Hope it helps!

wasil
  • 11
1

I've had persistent problems with Notepad++ (on 5.9) in regards to opening/editing files via explorer interface (both direct click to open and right-click to edit..etc). The solution for me has been to install Notepad++ in C:\Program Tools\Notepad++\ - if I try any of the "official" install locations Notepad++ only opens things right when run in admin mode (which is a UAC pain in the arse if you'll pardon my french)

hjhndr
  • 11
0

For those ending up with duplicate entries after following John Swaringen's or Laurie Stearn's, like Aske B, this is because these answers are incomplete and don't deal with the removal of the default entry. If you compare them to Steve's answer, they pick up where he says "Now we re-create it" and you still have to do the stuff he says before that to remove the default entry. You don't have to reinstall N++, though you can if you feel more comfortable doing that. Unfortunately, while a .reg file could be created to remove the default entry automatically, to make it easier for those who prefer not to do manual registry edits, it's not likely to work well, since it's probably in a different location for different people. Mine, for example, was in [HKEY_CLASSES_ROOT\CLSID{B298D29A-A6ED-11DE-BA8C-A68E55D89593}].

Another tidbit: If you want to change the location of the entry in the right-click menu, whether to make it be right under the top/default "Open" or "Open with" entry" (and keep in mind it may be when you create it but that may change later if/when another program creates a new entry, so you may want to just do this now to prevent that from happening later) or to move it down closer to the default entry's position (toward the bottom of the top section), you do this via the key name. For example, keys in this order will result in context menu entries in the same order:

[HKEY_CLASSES_ROOT*\shell\!EditWithNotepad] [HKEY_CLASSES_ROOT*\shell\AEditWithNotepad] [HKEY_CLASSES_ROOT*\shell\AnotherProgram] [HKEY_CLASSES_ROOT*\shell\EditWithNotepad] [HKEY_CLASSES_ROOT*\shell\OpenWithNotepad] [HKEY_CLASSES_ROOT*\shell\SomeOtherProgram] [HKEY_CLASSES_ROOT*\shell\ZOpenWithNotepad]

Keep in mind these are merely the key names, and they have no impact on the entries' text, only their positions. The actual text of the entry is determined by the "(Default)" name provided in the right pane. And, of course, you can use this to change the order of the other entries as well (top section only, though I'm sure the other sections can be tweaked elsewhere in the registry, plus I believe there are programs specifically for modifying the context menu.

vertigo
  • 53