Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

replace notepad with notepad++ in windows 7

Franco
2009-11-24
2014-05-19
  • Franco
    Franco
    2009-11-24

    Hello all,

    It looks likes this works for getting a replacement for notepad for notepad++ in Windows 7just by creating a registry key (so far it is working for me in Windows 7 - retail version, no beta).

    This is a partial copy of the instructions from but just remove the /z part otherwise notepad++ tried to open the z file:

    (http://www.neowin.net/forum/index.php?s=eb412239989288bc7e5cea9c230d7731&showtopic=817986&pid=591531366&mode=threaded&show=&st=#entry591531366)

    In order to use this method of Notepad replacement, you will need to follow these steps:

    1. Obtain a build of Notepad2 that supports this form of Notepad replacement.
    2. Create the following registry key: HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\notepad.exe.
    3. Inside the key, create a new string (REG_SZ) value, named "Debugger".
    4. Set the data of this new "Debugger" value to the full path to the Notepad2 executable, followed by the /z switch. For example, "C:\Windows\Notepad2.exe" /z

    Franco

     
    • Mattes H.
      Mattes H.
      2013-02-24

      Hi,

      if you like try my application I just developped with this perfect solution.
      https://sourceforge.net/projects/npplauncher/

      Best Regards
      Mattes H.

       
  • Franco
    Franco
    2009-11-24

    Sorry I should add that you need to change the Debugger path for notepad++ which should be:

    "C:\Program Files\Notepad++\notepad++.exe" /z

    Franco

     
  • Franco
    Franco
    2009-11-24

    Man..to fast to type..now when I double click any file that notepad usually uses notepad++ opens but it also opens the notepad.exe binary.  No biggee but not as polished as I as hoped since it was working…. back to the drawing board.

    Franco

     
  • cchris
    cchris
    2009-11-25

    Can you check (http://sourceforge.net/apps/mediawiki/notepadplus/index.php?yiyle=Replacing_Notepad) and check how your method fits in, possibly merging it into the page?

    Comparative reports on the methods exposed on the page are welcome, since they would help promoting a standard method to the download page and simply clear any confusion for new users.

    TIA 
    CChris

     
  • Franco
    Franco
    2009-11-25

    Hello CChris,

    I get an error when I try to go to the page:

    SourceForge.net > Error
    There was an error processing your request …

    Group not found for name: notepadplus

    Franco

     
  • Franco
    Franco
    2009-11-25

    Hello CChris,

    What is described on this page does not work on Windows 7:
    https://sourceforge.net/apps/mediawiki/notepad-plus/index.php?title=Replacing_Notepad

    If you double click an txt file it says it wants to create a C:\program file.  So it looks like the quotation marks are the culprit.  I tried a few variances of the actual command but with no luck. 

    I think the best way is to find the default txt extension (right click and open with) and do it that way.  From what I have been reading using the Image registry hack is an attack vector.

    I will look into how to manage extensions to a program via the registry and see how that goes.

    Franco

     
  • RubinX
    RubinX
    2009-11-29

    Hi.

    First of all, sorry for my English skills :(

    There are 2 problems with **passing parameters to** **Notepad++.exe**:

    - **1st extra parameter** (which in Windows XP is: **C:\WINDOWS\system32\NOTEPAD.EXE**)
    - path **with white spaces** is treat as **many** parameters instead of **one** (for example: **C:\Program Files\file.txt** --> **(1)** "**C:\Program**" and **(2)** "**Files\file.txt**")

    So all we need to do is **fix parameters** passed to Notepad++.exe:

    - **ignore 1st parameter**
    - **add double quotes "…"** to other parameters (for example: **C:\Program Files\file.txt** --> "**C:\Program Files\file.txt**")


    You may try this way to solve your problem:

    **1. Add / modify registry entry:**

        Windows Registry Editor Version 5.00
       
       
        "Debugger"="\"C:\\Program Files\\Notepad++\\Notepad++ParamProxy.exe\""

    (of course you may use any filename, instead of my: '***Notepad++ParamProxy.exe***' ;  and… **dont use "/z" switch** like Notepad2)

    **2. Now you need to build a tool program 'Notepad++ParamProxy.exe**':

    Modify and compile my sample source code in your favorite environment / compiler, (or just use ):

        //--------------------------------------------------
        #include <windows.h>
        #pragma hdrstop
        //--------------------------------------------------
        #define  NPP_BASE_DIR  "C:\\Program Files\\Notepad++\\"
        #define  NPP_EXE_NAME  "Notepad++.exe"
        //--------------------------------------------------
        #pragma argsused
        WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
        {
          // do nothing if first parameter is not path to Notepad.exe
          if (strncmpi(lpCmdLine + (lpCmdLine == '"' ? 1 : 0), "C:\\WINDOWS\\system32\\NOTEPAD.EXE", 31))
            return 0;

          char program = NPP_BASE_DIR NPP_EXE_NAME;
       
          int firstSpacePosition;
          for (firstSpacePosition = 0; firstSpacePosition < strlen(lpCmdLine); firstSpacePosition++)
            if (lpCmdLine == ' ')
              break;
       
          char parameters = "\"";
          strncat(parameters, lpCmdLine + firstSpacePosition + 1, MAX_PATH - 3);
          strcat(parameters, "\"");
       
          HINSTANCE result = ShellExecute(NULL, "open", program, parameters, NPP_BASE_DIR, SW_SHOW);
          if ((int)result <= 32)
          {
            char errorMessage = "Error:\n";
            FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, (int)result, 0, errorMessage + 7, 255 - 7, NULL);
            MessageBox(NULL, errorMessage, "Notepad to Notepad++ Parameters Proxy", MB_ICONERROR);
       
            return (int)result;
          }
       
          return 0;
        }
        //--------------------------------------------------

    I hope this will help you…

      : http://cinus.org/Notepad++ParamProxy.zip

     
  • RubinX
    RubinX
    2009-11-29

    oops, I pasted wrong code, sorry :/

    here is a bit better:

        //--------------------------------------------------
        #include <windows.h>
        #pragma hdrstop
        //--------------------------------------------------
        #define  NPP_BASE_DIR  "C:\\Program Files\\Notepad++\\"
        #define  NPP_EXE_NAME  "Notepad++.exe"
        //--------------------------------------------------
        #pragma argsused
        WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
        {
          // do nothing if first parameter is not path to Notepad.exe
       
          if (strncmpi(lpCmdLine + (lpCmdLine == '"' ? 1 : 0), "C:\\WINDOWS\\system32\\NOTEPAD.EXE", 31))
            return 0;
       
          char program = NPP_BASE_DIR NPP_EXE_NAME;
       
          int firstSpacePosition;
          for (firstSpacePosition = 0; firstSpacePosition < strlen(lpCmdLine); firstSpacePosition++)
            if (lpCmdLine == ' ')
              break;

          if ((lpCmdLine + firstSpacePosition + 1) == '"')
            firstSpacePosition += 1;

          // 
          // create new parameters string (ignore first original parameter and quote others if needed)
          //
          // for example:
          //
          // from  "C:\WINDOWS\system32\NOTEPAD.EXE" C:\Documents and Settings\Cinus\Pulpit\01.reg
          //
          // to    "C:\Documents and Settings\Cinus\Pulpit\01.reg"
          //

          char parameters = "";
          if (firstSpacePosition < strlen(lpCmdLine + (lpCmdLine == '"' ? 1 : 0)))
          {
            strcat(parameters, "\"");
            strncat(parameters, lpCmdLine + firstSpacePosition + 1, MAX_PATH - 3);
            if (parameters != '"')
              strcat(parameters, "\"");
          }

          // now execute the original 'Notepad++.exe' with fixed parameters
       
          HINSTANCE result = ShellExecute(NULL, "open", program, parameters, NPP_BASE_DIR, SW_SHOW);
          if ((int)result <= 32)
          {
            char errorMessage = "Error:\n";
            FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, (int)result, 0, errorMessage + 7, 255 - 7, NULL);
            MessageBox(NULL, errorMessage, "Notepad to Notepad++ Parameters Proxy", MB_ICONERROR);
       
            return (int)result;
          }
       
          return 0;
        }
        //--------------------------------------------------

     

  • Anonymous
    2009-12-02

    Well, this morning i manage to change the default notepad to notepad++ in Windows 7.

    You just need a tool to bypass the security on c:\windows and c:\windows\system32, you can find it in http://www.holacape.com/2009/11/se-requieren-permisos-de-trusted.html
    just go to both paths and rename notepad.exe to notepad.org  (or any other name) and copy the launcher from http://notepad-plus.sourceforge.net/commun/misc/NppLauncher.bin.zip in both paths and is done.
    Go start menu and launch Notepad in ussual way, and you'll get the Notepad Plus ;)

    Cheers

     
  •  elby
    elby
    2010-01-27

    Here is something easier:

    the problem lies in the fact that you can't delete notepad.exe in the Windows directory.

    You CAN delete it if you are its owner.  So make yourself its owner. (You must be an administrator!)

    Right click on notepad.exe in the Windows folder, select properties. 
    Choose Security. 
    Click Advanced. 
    Select Owner.
    Click Edit.
    Select yourself as owner.
    OK.
    Make sure you close the properties dialog for the changes to occur.

    Now you should be able to delete/rename notepad.exe

    You only need administrator privileges to copy the replacement notepad.exe from the Notepad++ replacer zip file.

     
  • bLiTzJoN
    bLiTzJoN
    2010-03-25

    Thanks Rubinx for the proxy, it works like a charm; I was about to do the very exact thing till I ran across this thread.  Since I'm using 64bit Win7 I had to install Npp in "C:\Program Files" (instead of "C:\Program Files (x86)") since you have it hard coded in the source - I would suggest some check to see if the npp executable is in the same directory as the paramproxy and take priority before looking at the hard coded location, or add a config file or commandline switch to override the hard value.

     
  • mll
    mll
    2010-08-30

    Hi there,

    I packeged the stuff provided by rubinx to make the process a bit easier. See http://mll2.free.fr/?p=273.

    Feedback / suggestions welcome !

     

  • Anonymous
    2010-11-17

    Hi every one.
    I have created a small one click utility that permits to replace the classic notepad with notepad++ using this non destructive method.
    I am positive it works on windows 7. I don't know for Vista or XP but I believe it should work.
    The difference with the previous utility is :
    * It detects the notepad++ install (wherever it is installed, not just the default directory)
    * It works on both 32bits and 64bits systems.
    * One click install and one click uninstall provided.

    http://www.megaupload.com/?d=ZHPO79C6

    The sources of both the installer and the parameter proxy are included.

    Hope you will find it usefull.

    Salomon.

     

  • Anonymous
    2010-11-17

    My apologies,
    I just discovered a bug in my param proxy.
    Here is the corrected working version :
    http://www.megaupload.com/?d=FE5DLQ7K

    Sorry again ;)

     
  • Piyush Soni
    Piyush Soni
    2010-11-19

    I didn't bother about replacing notepad, but added all the common file types like .txt, .log, .xml, .html etc. to open with Notepad++ by default. Also, I did another thing to launch it fast and type less: create a shortcut to Notepad++, and call it 'np'. Copy this shortcut to your C:\Windows\System32 directory. Now whenever you want to run NPP, you can just press Win + R buttons, and type np ->press enter.

     
  • Maloney
    Maloney
    2011-05-20

    Thanks for your Notepad-To-NotepadPP tool, worked great.

     

  • Anonymous
    2012-04-27

    There is another wery simple solution:
    1. Rename notepad.exe files in C:\Windows and C:\Windows\system32
    2. Add directory with your Notepad++ installation to Windows PATH variable (My Computer > Properties > Advanced Properties > Advanced > System variables; your PATH will like this:

    c:\Program Files (x86)\Notepad++;C:\Program Files (x86)\ImageMagick-6.7.6-Q16;C:\Program Files (x86)\ActiveState Komodo Edit 7\…

    3. open CMD, go to Notepad++ directory and create hardlink for notepad++.exe:

    mklink /h "notepad.exe" notepad++.exe

    Now you can press Win+R and type "notepad" and you`ll see N++

     

  • Anonymous
    2012-04-30

    I found an even simpler solution I've been using for quite awhile.  I create a bat file with the following contents:

    reg add "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\notepad.exe" /v "Debugger" /t REG_SZ /d "\"%~dp0notepad++.exe\" /z" /f
    pause
    

    Drop the bat in the same location as the executable and run it as administrator.. done.

     
    • Kimme Utsi
      Kimme Utsi
      2014-05-19

      This only makes....

      [Window Title]
      C:\Windows\notepad.exe

      [Content]
      Windows cannot find 'C:\Windows\notepad.exe'. Make sure you typed the name correctly, and then try again.

      [OK]