6
I'm trying to write a registry hack that will streamline some of my setup tasks when I create a new VM or repave my laptop. One thing I'm doing is switching to portable versions (synced in Dropbox) of a bunch of my favorite apps, including Notepad++.
I want to create a registry entry to allow me to have the Open with Notepad++ option in my right click menu, which is the only thing I'm missing with the portable version. I'm getting an error, though:
Windows cannot access the specified device, path or file. You may not have the
appropriate permissions to access the item.
Here's my .reg
file:
[HKEY_CLASSES_ROOT\*\shell\Open with Notepad++]
"Icon"="%USERPROFILE%\\Dropbox\\Programs\\Setup\\Icons\\Notepad++.ico"
@=""
[HKEY_CLASSES_ROOT\*\shell\Open with Notepad++\command]
@="%USERPROFILE%\\Dropbox\\Programs\\Notepad++\\notepad++.exe %1"
The icon works perfectly. I can get the entry above to work fine if I hardcode C:\Users\myusername
, but I'm going for portability here.
I'm pretty sure the issue is just finding the right escape sequence for the %
symbols, but it's hard to say.
Suggestions?
EDIT: I went with the add reg
command option, and after a bit of trial and error, here's the command that worked:
reg add HKCR\*\shell\OpenWithNotepad++\command /t REG_EXPAND_SZ /ve /d ^%USERPROFILE^%"\Dropbox\Programs\Notepad++\notepad++.exe %1"
After running the command, I exported the results as a .reg
file as well. Wins all around.
As crazy as it sounds, you can just put quotes around the spaces within the string.
reg add HKCR\*\shell\OpenWithNotepad++\command /t REG_EXPAND_SZ /ve /d ^%USERPROFILE^%\Dropbox\Programs\Notepad++\notepad++.exe" "%1
– jaylweb – 2016-06-08T20:18:04.753This was very helpful. Stuck on the syntax of the command, though:
reg add HKCR\*\shell\Open with Notepad++\command /t REG_EXPAND_SZ /ve /d ^%USERPROFILE^%\Dropbox\Programs\Notepad++\notepad++.exe %1
is generating a syntax error. Not really sure how to handle the space before the%1
, either... – Josh Earl – 2012-05-10T03:08:39.5602Put quotes around the strings... spaces get split into separate arguments, which becomes invalid syntax (more arguments than expected). – Bob – 2012-05-10T03:10:49.807