Community
    • Login

    [SOLVED][Tutorial][ShellExecute failed (2)] I can use "Edit with Notepad++" as administrator

    Scheduled Pinned Locked Moved General Discussion
    1 Posts 1 Posters 5.4k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Abdulrahman MohamedA
      Abdulrahman Mohamed
      last edited by guy038

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

      But 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.

      1. Open “Registry” (just type in windows search “registry” without quotes)
      2. In the right panel, right click on HKEY_CLASSES_ROOT then select “Find…”
      3. Search for Edit with Notepad++ and if you didn’t get a result, search for Edit with &Notepadd++

      q4f5OSDMsx1.png
      4. You should see the search results as in below screenshot, and delete the whole key: (Screenshot is from solution source)
      LEAMx4s67K.png
      ⚠️⚠️ 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:

      1. 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

      2. Opened it and started a registry scan as in screenshot, I searched instead with notepad++ to locate the key.
        I0HC7EKLRh.png

      3. 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:
        image830.png
        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++”

      4. 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.
        6hgeapNpXi.png
        ⚠️⚠️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:

      1. 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 it OpenWithNotepad and create a sub-key under that called command as seen below:
        cwvR0xuDbb.png (Screenshot is from the original solution page)

      2. Inside the OpenWithNotepad key, set the (Default) string variable to Edit with Notepad ++
        9K85UApqz1.png

      3. In the same key OpenWithNotepad , create a new string variable called icon and set the value to the full path of “notepad++.exe”. In my case, I had to set it to C:\Program Files\Notepad++\notepad++.exe where the program is installed.
        epC3UZoJhV.png
        okxdHLGk06.png

      4. Now go to command key and set the default string as "full path of notepad++.exe" "%1" as we did in step 7
        U2S85HfLKb.png

      5. That’s it. If you set Notepad++ to run as administraotr, try now to use “Edit with Notepad++” option and it should work.

      Notes:

      1. My Notepad++ version is 8.3.3, and it’s not portable, I installed it on my Windows 10.
      2. 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!
      3. 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/
      1 Reply Last reply Reply Quote 0
      • PeterJonesP PeterJones referenced this topic on
      • First post
        Last post
      The Community of users of the Notepad++ text editor.
      Powered by NodeBB | Contributors