My experience of command line input dates back some 30 years ago with basic Unix commands.
As does mine. And I use Linux escaping every day. And I still get Windows escaping wrong sometimes. :-)
But since you’re copying from someone else’s supposedly-tested command – and the version you quoted looks correct this time, rather than mangled by the forum – I no longer think it’s escaping.
resulting in the invalid syntax error
I don’t have write-permission to that area of the registry, even when running with Admin privileges, so I cannot test that exact command. However, using the same syntax, but going into an HKCU key instead (where I do have write privileges), I see:
C:\>reg add "HKCU\Software\Classes\.nppssn\dne" /v "Debugger" /t REG_SZ /d "\"%ProgramFiles(x86)%\Notepad++\notepad++.exe\" -notepadStyleCmdline -z" /f
The operation completed successfully.
C:\>reg query "HKCU\Software\Classes\.nppssn\dne" /v "Debugger"
Debugger REG_SZ "C:\Program Files (x86)\Notepad++\notepad++.exe" -notepadStyleCmdline -z
So the syntax seems right when using a different key.
(If I try to write to the key you quoted, I get ERROR: Access is denied., so I don’t think yours is a permission issue)
(I also see why it didn’t matter about REG_SZ vs REG_EXPAND_SZ: cmd.exe is expanding the variable before it gets put into the registry, so the registry key doesn’t need to be able to expand it)
I’m wondering if it’s the environment variable that it’s not knowing. If you’re on a 32-bit Windows OS, then it wouldn’t know that variable…
(Also, if you’ve got 64-bit Notepad++ on 64-bit windows, it’s not in the %ProgramFiles(x86)% anyway, but in the %ProgramFiles%, so you’d have to change that, as it mentioned on the page you cited)
You might also try an explicit path, rather than using the variable:
reg add "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\notepad.exe" /v "Debugger" /t REG_SZ /d "\"C:\Program Files (x86)\Notepad++\notepad++.exe\" -notepadStyleCmdline -z" /f
reg add "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\notepad.exe" /v "Debugger" /t REG_SZ /d "\"C:\Program Files\Notepad++\notepad++.exe\" -notepadStyleCmdline -z" /f
(depending on where notepad++ is installed)
If that still claims syntax error for you, I really think you should try to input the key with regedit directly. If you want REG_SZ (ie, a “string” value), then you should not input the %ProgramFiles(x86)% variable, but instead use the fully-expanded path; if you use REG_EXPAND_SZ (ie, an “expandable string” value), then feel free to use the variable-notation, even in the registry entry.