build 7.6 "open with..." association does not open files with spaces in filenames
-
Builds up to an including 7.5.8 could be added to the Windows context menu to open any file. Here is the .reg file which allows this:
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT*\shell\Notepad++]
@=“Edit with &Notepad++”
“Icon”=“C:\Portable\- Linked\Notepad++\notepad++.exe,0”[HKEY_CLASSES_ROOT*\shell\Notepad++\Command]
@=“C:\Portable\- Linked\Notepad++\Notepad++.exe %L”
Build 7.6 will NOT open files with spaces in their filenames.
Why is this and what can be done to fix the problem?
-
Fix = put quotes around
%L
in the registry:Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT*\shell\Notepad++] @="Edit with &Notepad++" "Icon"="C:\Portable\- Linked\Notepad++\notepad++.exe,0" [HKEY_CLASSES_ROOT*\shell\Notepad++\Command] @="C:\Portable\- Linked\Notepad++\Notepad++.exe \"%L\""
The “why” = the author changed handling of command-line arguments to be more consistent with other windows programs, where filenames with spaces on the command line must be surrounded by quotes to be interpreted as a single filename.
-
example for the why = otherwise,
notepad++.exe a file here.txt
would be ambiguous as to whether it’s opening one file called
a file here.txt
with spaces in the name, or whether it’s opening three files – one calleda
, one calledfile
, and one calledhere.txt
.If all four files existed, it would be impossible to grok your intention.
Now, it requires
notepad++.exe "a file here.txt"
to tell it that it’s one filename, and will assume multiple filenames if there aren’t quotes around it.
-
Are you sure the registry code above is correctly spelled? I tried this (adjusted for my Notepad++ location) but I get a registry error “This file doesn’t have associated program…”
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT*\shell\Notepad++]
@=“Edit with &Notepad++”
“Icon”=“C:\Notepad++\notepad++.exe,0”[HKEY_CLASSES_ROOT*\shell\Notepad++\Command]
@=“C:\Notepad++\Notepad++.exe “%L””Thanks!
-
Sorry, no – I had just copy/edit/pasted what was originally posted by @FredThompsonII , and didn’t notice that it was missing a
\
before the*
. For your example, I believe it should be:Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT\*\shell\Notepad++] @="Edit with &Notepad++" "Icon"="C:\\Notepad++\\notepad++.exe,0" [HKEY_CLASSES_ROOT\*\shell\Notepad++\command] @="C:\\Notepad++\\Notepad++.exe \"%L\""
-----
Aside: I believe what happened is that because the original poster did not indent the.reg
text four spaces in the forum, the forum software converted the quotes to “smart quotes” (which I noticed and fixed) and also converted the\*
to a plain*
– it interpreted it as escaping the*
character (which is used to start/stop emphasis and bold) instead of as wanting a literal\*
. It also probably changed the\\
in the paths to\
, and possibly converted\"
to just“
. That’s why Markdown provides the indenting feature for code blocks – to tell Markdown to treat the text as purely literal. I believe I have correctly edited your example to include all the correct escaping and quotes.In case it’s not, here’s my example from my registry: it’s for the “txtfile” entry, rather than the “*” entry, but it shows the syntax properly (because I know this association works):
Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT\txtfile\shell\Notepad++] @="Notepad++" [HKEY_CLASSES_ROOT\txtfile\shell\Notepad++\command] @="C:\\Program Files (x86)\\Notepad++\\notepad++.exe \"%1\""
-----
edit: note: see this post for a link describing %1 vs %L in registry entries. -
extra: in case you’re curious, since the OP used
%L
but my example used%1
: see this post for a link describing %1 vs %L in registry entries. In short: it doesn’t really matter in this case, because the difference is only significant on old 16bit windows OS (like Win3.11). On modern Windows,%L
and%1
are interchangeable in the registry associations. (Only%1
works in.bat
/.cmd
files, though, which is why I’ve gotten used to using%1
.)