[SOLVED][Tutorial][ShellExecute failed (2)] I can use "Edit with Notepad++" as administrator
-
We all know this error when we right click a file and choose “Edit with Notepad++”:
ShellExecute Failed (2): Is this command correct? “C:\Program Files (x86)\Notepad++\Notepad++.exe” “Path Of File Your Want To Open\FileName.txt”
This is caused because Notepad++ is launched with administrator privileges, so the solution was to navigate to Notepad++ installation path then right click on “Notepad++.exe” and uncheck “Run the program as administrator” as stated here:
https://community.notepad-plus-plus.org/topic/14750/shellexecute-failed-2-is-this-command-correctBut I found a solution and it worked for me where you can launch Notepad++ as admin and still be able to use that option.
The solution is taken from here:
http://timourrashed.com/how-to-fix-shellexecute/
(A snapshot of the page here, just in case: http://web.archive.org/web/20220423043635/http://timourrashed.com/how-to-fix-shellexecute/)Solution is to locate and delete the registry key that is responsible for integrating “Edit with Notepad++” option in the Right Click Menu and create another one in “HKEY_CLASSES_ROOT*\shell” to be able to use the option while running Notepad++ as administrator.
ℹ️ Solution Steps:
⚠️⚠️ It’s very important to read all steps before doing anything because I reproduced the first fours steps with my way to locate the key we want to delete.⚠️⚠️ I’m not responsible for any damage, you do it at your own risk.
- Open “Registry” (just type in windows search “registry” without quotes)
- In the right panel, right click on
HKEY_CLASSES_ROOT
then select “Find…” - Search for
Edit with Notepad++
and if you didn’t get a result, search forEdit with &Notepadd++
4. You should see the search results as in below screenshot, and delete the whole key: (Screenshot is from solution source)
⚠️⚠️ Backup Warning: Before you delete anything, you should backup the registry key just in case of errors afterwards, and this can be done by right click on the key you want to backup (the folder) then click “Export”
So that you can double click the backed-up registry file and then hit “Merge” to restore the key if you want to revert changes.
(You can backup the entire registry too, refer to below article on how to backup)
How to Backup and Restore the Windows Registryℹ️⚠️ I did the last fours steps but didn’t receive search results with any of those two values, looks like this was in older versions of Notepad++.
So what I did is reproduce the fours steps:-
Since the built-in search in registry is too slow, I downloaded “RegScanner v2.65” from “Nirsoft” to search for the key, it was faster.
http://www.nirsoft.net/utils/regscanner.html -
Opened it and started a registry scan as in screenshot, I searched instead with
notepad++
to locate the key.
-
After completed the search, I located the key by comparing the “data” value column with the screenshot from the solution source then opened it in Registry:
The data value is{B298D29A-A6ED-11DE-BA8C-A68E55D89593}
which if you searched with, you should be able to locate it instantly instead of searching with “notepad++” -
Now the Registry will be opened and you can delete the key, and you should see that “Edit with Notepad++” option from is deleted from right click menu.
⚠️⚠️Please refer to the “Backup Warning” up before you delete anything.
Now we will continue the rest of solution which is creating the replacement key:
-
In Registry go to
HKEY_CLASSES_ROOT\*\shell
and right click on “shell” key then select “New > Key” to create new key, you will name itOpenWithNotepad
and create a sub-key under that calledcommand
as seen below:
(Screenshot is from the original solution page) -
Inside the
OpenWithNotepad
key, set the(Default)
string variable toEdit with Notepad ++
-
In the same key
OpenWithNotepad
, create a new string variable calledicon
and set the value to the full path of “notepad++.exe”. In my case, I had to set it toC:\Program Files\Notepad++\notepad++.exe
where the program is installed.
-
Now go to
command
key and set the default string as"full path of notepad++.exe" "%1"
as we did in step 7
-
That’s it. If you set Notepad++ to run as administraotr, try now to use “Edit with Notepad++” option and it should work.
Notes:
- My Notepad++ version is 8.3.3, and it’s not portable, I installed it on my Windows 10.
- I don’t know what will happen when new update releases for Notepad++, maybe we will reproduce same steps or delete only the responsible key? I really don’t know!
- Credits goes to the source I took the solution from and to the other sources if he copied it:
http://timourrashed.com/how-to-fix-shellexecute/
-