Community
    • Login

    Replace Notepad

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    9 Posts 3 Posters 3.0k 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.
    • Jim FitzGeraldJ
      Jim FitzGerald
      last edited by

      I have a Windows 10 PC and wished to replace Notepad with Notepad++
      So using Admin command prompt, entered the command reg add “HKLM\Software\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\notepad.exe” /v “Debugger” /t REG_SZ /d “”%ProgramFiles%\Notepad++\notepad++.exe" -notepadStyleCmdline -z" /f and pressed enter. Got the response ERROR: Invalid syntax.
      Type “REG ADD /?” for usage.

      Where have I gone wrong?

      1 Reply Last reply Reply Quote 0
      • PeterJonesP
        PeterJones
        last edited by

        @Jim-FitzGerald said:

        reg add “HKLM\Software\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\notepad.exe” /v “Debugger” /t REG_SZ /d “”%ProgramFiles%\Notepad++\notepad++.exe" -notepadStyleCmdline -z" /f

        It’s hard to tell, because the forum mangled your quotes into “smart quotes”. To avoid that, use backticks around the text you are quoting (like `blah "hey" blah` will render as blah "hey" blah instead of blah “hey” blah). Or put it on a line by itself (blank lines surrounding) indented four spaces:

        reg add "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\notepad.exe" /v "Debugger" /t REG_SZ /d ""%ProgramFiles%\Notepad++\notepad++.exe" -notepadStyleCmdline -z" /f 
        rem - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ^^
        

        You may notice there’s two double quotes next to each other. the cmd.exe prompt won’t handle embedded quotes the way you want. You would have to do escaping… and getting that escaping right is sometimes a pain. Personally, if I were just editing one entry in the registry, I would just run regedit (in admin mode, of course), and add the value/data pair to the correct key using the GUI. That way you don’t have to worry about the command-line escaping. Oh, and given that you’re using %-notation for %ProgramFiles%, I would recommend choosing “expandable string value” rather than “string value” – that sometimes makes a difference whether or not the environment value will expand.

        Good luck.

        (Personally, I just associate .txt and other such extensions with Notepad++, rather than trying to “replace” windows’ notepad.exe… but it’s up to you.)

        Jim FitzGeraldJ 1 Reply Last reply Reply Quote 1
        • Jim FitzGeraldJ
          Jim FitzGerald @PeterJones
          last edited by

          @PeterJones Hi Peter
          Thanks for that.
          My experience of command line input dates back some 30 years ago with basic Unix commands.
          So I took the command from this page;
          https://notepad-plus-plus.org/features/replace-notepad.html
          And copied it thus;

          reg add "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\notepad.exe" /v "Debugger" /t REG_SZ /d "\"%ProgramFiles(x86)%\Notepad++\notepad++.exe\" -notepadStyleCmdline -z" /f
          

          And pasted it in to the admin command window, resulting in the invalid syntax error

          1 Reply Last reply Reply Quote 0
          • PeterJonesP
            PeterJones
            last edited by

            @Jim-FitzGerald said:

            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

            Strange.

            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"
            
            HKEY_CURRENT_USER\Software\Classes\.nppssn\dne
                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
            

            or

            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.

            1 Reply Last reply Reply Quote 0
            • Jim FitzGeraldJ
              Jim FitzGerald
              last edited by

              Hi Peter
              I tried your second option; same result…
              As I don’t feel comfortable tinkering with the Registry - Windows is a pane, I’ll follow your first suggestion of changing file association!
              Thanks for your help.

              1 Reply Last reply Reply Quote 1
              • Michael VincentM
                Michael Vincent
                last edited by

                @Jim-FitzGerald said:

                Windows is a pane

                LOL - nice pun!

                Jim FitzGeraldJ 1 Reply Last reply Reply Quote 1
                • Jim FitzGeraldJ
                  Jim FitzGerald @Michael Vincent
                  last edited by

                  @Michael-Vincent
                  Thanks; been itching to use that one for years!

                  1 Reply Last reply Reply Quote 0
                  • PeterJonesP
                    PeterJones
                    last edited by

                    @Jim-FitzGerald said:

                    I don’t feel comfortable tinkering with the Registry

                    “reg add” is as much tinkering with the registry as “regedit”, but without the meaningful feedback and ability to immediately see the changes. But if you don’t want to use regedit, that’s your choice.

                    And yes, file associations is a good way to go.

                    Jim FitzGeraldJ 1 Reply Last reply Reply Quote 0
                    • Jim FitzGeraldJ
                      Jim FitzGerald @PeterJones
                      last edited by

                      @PeterJones
                      Thanks Peter!

                      1 Reply Last reply Reply Quote 1
                      • First post
                        Last post
                      The Community of users of the Notepad++ text editor.
                      Powered by NodeBB | Contributors