Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error (shellExecute) when trying to open files from context menu #8786

Closed
FuccDucc opened this issue Sep 1, 2020 · 9 comments
Closed

Error (shellExecute) when trying to open files from context menu #8786

FuccDucc opened this issue Sep 1, 2020 · 9 comments

Comments

@FuccDucc
Copy link

FuccDucc commented Sep 1, 2020

Description of the Issue

If you run Notepad++ in compatibility mode ("Run as Administrator"), you may get the following error when you try to open files using the Windows context menu (that is, right click the file and select "Edit with Notepad++"):

ShellExecute failed (2): Is this command correct?
"C:\Program Files\Notepad++\notepad++.exe"
"C:\Users\Username\Desktop\textfile.txt"

The window name is "Notepad++ Extension: Error" and the window icon is Windows Explorer icon. Even though this happens for me with a clean installation of Notepad++, so without any non-standard extensions or plugins.

Screenshot of the error:
error

Steps to Reproduce the Issue

  1. Install Notepad++ 7.8.9 (x64)
  2. Go to Notepad++ install folder and right click notepad++.exe file > properties > compatibility > enable "Run this program as Administrator"
  3. Right-click any file on your hard disk that Notepad++ can open, and select "Edit with Notepad++"
  4. Observe error

Expected Behavior

Notepad++ should be able to open files in this manner despite running itself as Administrator. Some people intuitively want to run editors like Notepad++ as admin, to avoid errors of a lack of file access or locked files for which Notepad++ asks the user to restart with administrator privileges, in order to be able to save it. These advanced users might enable this setting in compatibility tab, no matter how effective it is, and will now run into this unnecesary error, and will probably have a hard time figuring out the reason for their error.

Actual Behavior

Notepad++ couldn't open a file using the context menu

@FuccDucc
Copy link
Author

Bump!

@mere-human
Copy link
Contributor

Ok, I can confirm this is still an issue in Notepad++ 7.9.4.
Also, the error code "2" means ERROR_FILE_NOT_FOUND.
Probably, we should use different arguments for ShellExecute when in admin mode.

Debug info:

Notepad++ v7.9.4   (32-bit)
Build time : Mar 15 2021 - 01:00:14
Path : C:\Program Files (x86)\Notepad++\notepad++.exe
Admin mode : ON
Local Conf mode : OFF
OS Name : Windows 10 Enterprise (64-bit) 
OS Version : 2009
OS Build : 19042.867
Current ANSI codepage : 1252
Plugins : ComparePlugin.dll HexEditor.dll MarkdownViewerPlusPlus.dll mimeTools.dll NppConverter.dll NppExec.dll NppExport.dll NppMarkdownPanel.dll NppTextFX.dll PythonScript.dll 

@FuccDucc
Copy link
Author

FuccDucc commented May 7, 2021

Apparently this is a widespread issue, judging by this search: Google: "ShellExecute failed (2): Is this command correct?"

There are 10 pages of people asking for help getting this issue. There is also duplicate issues on the tracker (but not better than this one, and mostly focussed on workarounds, not getting it fixed properly in Notepad++). How is it not fixed after so many years? @donho

@ArkadiuszMichalski
Copy link
Contributor

Duplicate of #4368.

@whawn1
Copy link

whawn1 commented Feb 14, 2023

Duplicated this behavior on install from internal v8.4.7 updater to v8.4.8. Had not seen it before in over ten years of use. Uninstalled and reinstalled clean -- and my desktop rearranged itself, but the NP++ behavior remained. Did a system restore, which put back v8.4.7 (and my carefully curated desktop), and the behavior persists. (and, oddly enough, I just discovered, drag-n-drop no longer works on the desktop, but does elsewhere???)

What would it take to reopen this issue?

Bug data after first install:
Notepad++ v8.4.8 (64-bit)
Build time : Dec 24 2022 - 19:40:27
Path : C:\Program Files\Notepad++\notepad++.exe
Command Line : C:\Users\user1\Desktop\Alt-Symbols.txt
Admin mode : ON
Local Conf mode : OFF
Cloud Config : OFF
OS Name : Windows 10 Home (64-bit)
OS Version : 21H2
OS Build : 19044.1706
Current ANSI codepage : 1252
Plugins :
DSpellCheck (1.4.23)
HexEditor (0.9.12)
mimeTools (2.9)
NppConverter (4.5)
NppExport (0.4)

Bug data after system restore:
Notepad++ v8.4.7 (64-bit)
Build time : Nov 1 2022 - 23:31:11
Path : C:\Program Files\Notepad++\notepad++.exe
Command Line :
Admin mode : ON
Local Conf mode : OFF
Cloud Config : OFF
OS Name : Windows 10 Home (64-bit)
OS Version : 21H2
OS Build : 19044.1706
Current ANSI codepage : 1252
Plugins :
DSpellCheck (1.4.23)
HexEditor (0.9.12)
mimeTools (2.9)
NppConverter (4.5)
NppExport (0.4)

@alankilborn
Copy link
Contributor

alankilborn commented Feb 14, 2023

drag-n-drop no longer works on the desktop, but does elsewhere???

Due to Admin mode : ON, maybe?

(ah, I can see this whole issue is predicated on admin mode...ugh).

@whawn1
Copy link

whawn1 commented Feb 14, 2023

Addendum: Uninstalled it all w/Revo uninstaller, took out all associated files and registry entries. Reinstalled from DLed v8.4.8 installer. Original issue remains. Will not open file from right click menu w/ 'run as admin' active on either the exe or the shortcut. Make it inactive, works just fine -- but holy cow, half (maybe more) of the files I work on need admin permissions. This is, to be mellow about it, highly annoying.
(H'ever, drag & drop now works on desktop ::sigh of relief:: )

@FuccDucc
Copy link
Author

FuccDucc commented Feb 15, 2023

What would it take to reopen this issue?

The problem is, they don't care
This should be a very easy bug to fix, but i see them doing so many other things, yet completely ignoring this one for years. @donho included

Apparently they are feature focused, not QoL focused.

Even no matter the high amount of duplicates/people asking about it

@donho
Copy link
Member

donho commented Feb 15, 2023

@FuccDucc

The problem is, they don't care
This should be a very easy bug to fix, but i see them doing so many other things, yet completely ignoring this one for years. @donho included

No, I ensure you that it's not true.
I have spent time to investigate this issue, but apparently when admin checkbox is check, the OS treats ShellExecute call differently.
And I don't think it's a trivial issue to fix - there are a lot of contributors who check and fix most wanted/complaint issues and they are even more competent than I am. If people had any solution, the issue would have solved since longtime ago.

With the deployment of Windows11 everywhere from Microsoft, I think it's better to abandon the old explorer context mechanism (NppShell.dll), and I'm considering using another solution instead - with which it works with normal or admin mode.

However, with admin mode people will complain about another issue - there'll be always a prompt to ask user if he/she wants to launch Notepad++ in Admin mode for each time you use "Edit with Notepad++", even an instance of Notepad++ in Admin mode is already there. But such issue won't be solved as I see no solution for it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants