Menu

File association

2007-10-27
2013-05-15
  • Nobody/Anonymous

    I've been giving NPP a serious look, and I'm very impressed with what it does. But for me, the current method of file association is a deal breaker.

    I keep coming back to the way that TextEdit handles associations. When you associate a file type with TextEdit, it doesn't change the icon (except for .txt files) and it doesn't change the description in Explorer. So for example, my .pas files still say 'Delphi Source File', and my XML files still say 'XML Document', and they all still have the icons they used to have.

    These are both crucial for me. I need to be able to look at a file's icon and tell what app it belongs to (not what text editor I choose to open it in), and I need to see these all grouped properly in Explorer windows.

    I'm aware that I can fix this all by hand, by mucking around in the registry. But it would be nicer if NPP handled this a little better.

     
    • Nobody/Anonymous

      I´ve tried it with .xml, it opens the xml file but gives an error,
      cannot open the (IE)-Site, or so!

      Is anything wrong with the regcode, can anyone help?
      OS Win XP 32 Prof.

      ~~~~~~~~~ Regcode start ~~~~~~~~

      Windows Registry Editor Version 5.00

      [HKEY_CLASSES_ROOT\.xml]
      @="Notepad++_xml"
      "Notepad++_backup"="xmlfile"
      "Content Type"="text/xml"

      [HKEY_CLASSES_ROOT\Notepad++_xml]
      @="Notepad++ XML Document"
      "EditFlags"=dword:00010000
      "FriendlyTypeName"="@C:\\WINDOWS\\system32\\msxml3r.dll,-1"

      [HKEY_CLASSES_ROOT\Notepad++_xml\BrowseInPlace]
      @=""

      [HKEY_CLASSES_ROOT\Notepad++_xml\CLSID]
      @="{48123BC4-99D9-11D1-A6B3-00C04FD91555}"

      [HKEY_CLASSES_ROOT\Notepad++_xml\DefaultIcon]
      @="C:\\WINDOWS\\system32\\msxml3.dll,0"

      [HKEY_CLASSES_ROOT\Notepad++_xml\shell]

      [HKEY_CLASSES_ROOT\Notepad++_xml\shell\Edit]

      [HKEY_CLASSES_ROOT\Notepad++_xml\shell\Edit\command]
      @="\"C:\\Programme\\Notepad++\\notepad++.exe\" \"%1\""

      [HKEY_CLASSES_ROOT\Notepad++_xml\shell]

      [HKEY_CLASSES_ROOT\Notepad++_xml\shell\Open]

      [HKEY_CLASSES_ROOT\Notepad++_xml\shell\Open\command]
      @="\"C:\\Programme\\Internet Explorer\\iexplore.exe\" -nohome"

      [HKEY_CLASSES_ROOT\Notepad++_xml\shell\Open\ddeexec]
      @="\"file:%1\",,-1,,,,,"

      [HKEY_CLASSES_ROOT\Notepad++_xml\shell\Open\ddeexec\application]
      @="IExplore"

      [HKEY_CLASSES_ROOT\Notepad++_xml\shell\Open\ddeexec\topic]
      @="WWW_OpenURL"

      ~~~~~~~~~~ Regcode end ~~~~~~~~~~

       
      • Nobody/Anonymous

        I just tried your regcode and it worked on my Windows XP Pro.

        If you revert back to using "xmlfile" for the .xml key, does the error go away and work.

        In this case, if you just want to add an edit for Notepad++, add the following to the xmlfile key.

        ~~~~~~~~~ Regcode start ~~~~~~~~
        Windows Registry Editor Version 5.00

        [HKEY_CLASSES_ROOT\xmlfile\shell\edit_with_notepad++]
        @="Edit with Notepad++"

        [HKEY_CLASSES_ROOT\xmlfile\shell\edit_with_notepad++\command]
        @="\"C:\\Program Files\\Notepad++\\notepad++.exe\" \"%1\""
        ~~~~~~~~~~ Regcode end ~~~~~~~~~~

        This will add a new right click context menu called "Edit with Notepad++" and will preserve the default open and edit.

         
    • Nobody/Anonymous

      I agree..  and even worse..  if you associate npp with bat files, they wont run anymore.. they'll open in npp when trying to run them.. BAD BAD BAD!!!

       
      • Nobody/Anonymous

        At http://dougknox.com/xp/file_assoc.htm is .reg file to restore original file association for .bat files. Otherwise I like Notepad++, but removing of old file associations is not acceptable.

         
      • CodeNexus

        CodeNexus - 2007-10-30

        Terrible infact.  Really terrible that you are associating it with .bat files...  don't do it because it isn't a smart thing to do.

         
        • Nobody/Anonymous

          Agreed - VBS files causes the same issue (when you execute them they simply open in NPP). SInce it's so "easy" to associate them, there should be some thought as to how they assigned (I know that this does not matter in ASP and some other "source" languages, like CXX< in fact it's an advantage (click and it opens), but in executable script files (BAT, VBS, etc.) it shoudl default to just takign over the "editing" bit.

           
    • Nobody/Anonymous

      First off - great product. As with otheres, my only issue is how NPP handles file association.

      When working with BAT, CMD, VBS, etc.; NPP replaces the open command - which then prevents the ability to execute the scripts.

      I started looking at the registry to see how NPP associates to file extensions.

      NPP creates one entry key under the HKEY_CLASSES_ROOT called "Notepad++_file". See below for the full registry entry.

      In my opinion, this is NPP's down fall. By only creating one entry, all extensions are associated to this key. Notice there is no "edit" key under the "shell" key. The "open" key is set to use NPP to open files. As some of us have experienced, this causes problems with a file with the BAT, CMD, VBS, etc. extensions. Instead of executing the script, it opens it into NPP.

      Actually, with some file extensions (i.e., BAT & CMD), there should also be a print menu option. This is gone after associating to NPP.

      Let's take the BAT extension as an example. Below is how it looks like in the registry before associating to NPP.

      ----------------------------------------------------------------
      Windows Registry Editor Version 5.00

      [HKEY_CLASSES_ROOT\.bat]
      @="batfile"

      [HKEY_CLASSES_ROOT\.bat\PersistentHandler]
      @="{5e941d80-bf96-11cd-b579-08002b30bfeb}"
      ----------------------------------------------------------------

      Below is how it looks like after it's associated to NPP.

      ----------------------------------------------------------------
      Windows Registry Editor Version 5.00

      [HKEY_CLASSES_ROOT\.bat]
      @="Notepad++_file"
      "Notepad++_backup"="batfile"

      [HKEY_CLASSES_ROOT\.bat\PersistentHandler]
      @="{5e941d80-bf96-11cd-b579-08002b30bfeb}"
      ----------------------------------------------------------------

      Notice the default string value is "Notepad++_file". Below is the registry entry for "Notepad++_file". Notice there are no Edit or Print entries. Just an Open, which overrides the default execute behavior for this file extension.

      ----------------------------------------------------------------
      Windows Registry Editor Version 5.00

      [HKEY_CLASSES_ROOT\Notepad++_file]
      @="Notepad++ Document"

      [HKEY_CLASSES_ROOT\Notepad++_file\shell]

      [HKEY_CLASSES_ROOT\Notepad++_file\shell\open]

      [HKEY_CLASSES_ROOT\Notepad++_file\shell\open\command]
      @="\"C:\\Program Files\\Notepad++\\notepad++.exe\" \"%1\""
      ----------------------------------------------------------------

      Below is how the "batfile" (default definition by Windows for BAT extensions) entries look like in the registry. Notice it has Edit, Open, and Print entries. Also notice it contains the icon for this extension and the name of this type (MS-DOS Batch File).

      ----------------------------------------------------------------
      Windows Registry Editor Version 5.00

      [HKEY_CLASSES_ROOT\batfile]
      @="MS-DOS Batch File"
      "EditFlags"=hex:30,04,00,00

      [HKEY_CLASSES_ROOT\batfile\DefaultIcon]
      @=hex(2):25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,00,25,\
        00,5c,00,53,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,73,00,68,00,\
        65,00,6c,00,6c,00,33,00,32,00,2e,00,64,00,6c,00,6c,00,2c,00,2d,00,31,00,35,\
        00,33,00,00,00

      [HKEY_CLASSES_ROOT\batfile\shell]

      [HKEY_CLASSES_ROOT\batfile\shell\edit]

      [HKEY_CLASSES_ROOT\batfile\shell\edit\command]
      @=hex(2):25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,00,25,\
        00,5c,00,53,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,4e,00,4f,00,\
        54,00,45,00,50,00,41,00,44,00,2e,00,45,00,58,00,45,00,20,00,25,00,31,00,00,\
        00

      [HKEY_CLASSES_ROOT\batfile\shell\open]
      "EditFlags"=hex:00,00,00,00

      [HKEY_CLASSES_ROOT\batfile\shell\open\command]
      @="\"%1\" %*"

      [HKEY_CLASSES_ROOT\batfile\shell\print]

      [HKEY_CLASSES_ROOT\batfile\shell\print\command]
      @=hex(2):25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,00,25,\
        00,5c,00,53,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,4e,00,4f,00,\
        54,00,45,00,50,00,41,00,44,00,2e,00,45,00,58,00,45,00,20,00,2f,00,70,00,20,\
        00,25,00,31,00,00,00

      [HKEY_CLASSES_ROOT\batfile\shellex]

      [HKEY_CLASSES_ROOT\batfile\shellex\DropHandler]
      @="{86C86720-42A0-1069-A2E8-08002B30309D}"

      [HKEY_CLASSES_ROOT\batfile\shellex\PropertySheetHandlers]

      [HKEY_CLASSES_ROOT\batfile\shellex\PropertySheetHandlers\PifProps]
      @="{86F19A00-42A0-1069-A2E9-08002B30309D}"

      [HKEY_CLASSES_ROOT\batfile\shellex\PropertySheetHandlers\ShimLayer Property Page]
      @="{513D916F-2A8E-4F51-AEAB-0CBC76FB1AF8}"
      ----------------------------------------------------------------

      I've reviewed how other editors update the registry properly. Below is an example. First off, NPP should create an entry for each extension (i.e., Notepad++_bat, Notepad++_cmd, Notepad++_txt, Notepad++_ini, etc.). Let's take the BAT extension as an example. Most of these are copied from the "batfile" key. For the BAT extension, I updated the Edit key so it would edit the BAT file into NPP.

      ----------------------------------------------------------------
      Windows Registry Editor Version 5.00

      [HKEY_CLASSES_ROOT\Notepad++_bat]
      @="MS-DOS Batch File"
      "EditFlags"=hex:30,04,00,00

      [HKEY_CLASSES_ROOT\Notepad++_bat\DefaultIcon]
      @=hex(2):25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,00,25,\
        00,5c,00,53,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,73,00,68,00,\
        65,00,6c,00,6c,00,33,00,32,00,2e,00,64,00,6c,00,6c,00,2c,00,2d,00,31,00,35,\
        00,33,00,00,00

      [HKEY_CLASSES_ROOT\Notepad++_bat\shell]

      [HKEY_CLASSES_ROOT\Notepad++_bat\shell\edit]

      [HKEY_CLASSES_ROOT\Notepad++_bat\shell\edit\command]
      @="\"C:\\Program Files\\Notepad++\\notepad++.exe\" \"%1\""

      [HKEY_CLASSES_ROOT\Notepad++_bat\shell\open]
      "EditFlags"=hex:00,00,00,00

      [HKEY_CLASSES_ROOT\Notepad++_bat\shell\open\command]
      @="\"%1\" %*"

      [HKEY_CLASSES_ROOT\Notepad++_bat\shell\print]

      [HKEY_CLASSES_ROOT\Notepad++_bat\shell\print\command]
      @=hex(2):25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,00,25,\
        00,5c,00,53,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,4e,00,4f,00,\
        54,00,45,00,50,00,41,00,44,00,2e,00,45,00,58,00,45,00,20,00,2f,00,70,00,20,\
        00,25,00,31,00,00,00

      [HKEY_CLASSES_ROOT\Notepad++_bat\shell\printto]

      [HKEY_CLASSES_ROOT\Notepad++_bat\shell\printto\command]
      @="\"C:\\Program Files\\TextPad 5\\TextPad.exe\" -s -pt \"%1\" \"%2\" \"%3\" \"%4\""

      [HKEY_CLASSES_ROOT\Notepad++_bat\shellex]

      [HKEY_CLASSES_ROOT\Notepad++_bat\shellex\DropHandler]
      @="{86C86720-42A0-1069-A2E8-08002B30309D}"

      [HKEY_CLASSES_ROOT\Notepad++_bat\shellex\PropertySheetHandlers]

      [HKEY_CLASSES_ROOT\Notepad++_bat\shellex\PropertySheetHandlers\PifProps]
      @="{86F19A00-42A0-1069-A2E9-08002B30309D}"

      [HKEY_CLASSES_ROOT\Notepad++_bat\shellex\PropertySheetHandlers\ShimLayer Property Page]
      @="{513D916F-2A8E-4F51-AEAB-0CBC76FB1AF8}"
      ----------------------------------------------------------------

      After adding the entries above, the default value under the ".bat" key is updated to "Notepad++_bat".

      ----------------------------------------------------------------
      Windows Registry Editor Version 5.00

      [HKEY_CLASSES_ROOT\.bat]
      @="Notepad++_bat"
      "Notepad++_backup"="batfile"

      [HKEY_CLASSES_ROOT\.bat\PersistentHandler]
      @="{5e941d80-bf96-11cd-b579-08002b30bfeb}"
      ----------------------------------------------------------------

      For those people who are familiar with updating the registry, try it for yourself.

      After the change, notice the following:

      1. The Windows default icon is the default Windows icon for this extension.
      2. The type name is "MS-DOS Batch File" and not "Notepad++ Document".
      3. Double clicking on the file executes the batch file.
      4. Right-click now has the edit menu; which launches NPP.
      5. Right click still has a Print menu option.
      6. Notice when sorting in Windows Explorer, all file extensions are group together - instead of all of them being sorted under Notepad+++ Document.

      In my opinion, each file extension that NPP associates to should have it's own registry key.

      bat = Notepad++_bat
      cmd = Notepad++_cmd
      vbs = Notepad++_vbs
      txt = Notepad++_txt
      ini = Notepad++_ini
      txt = Notepad++_txt

      This way, each file extension will maintain it's default icon and type name. In some cases like TXT, INI extensions, the Open menu command is fine to use. No need to add an Edit entry.

      Again, great product.

      I'm still going to continue using NPP, now that I know I can manually update the registry to handle file association properly. But it sure would be nice if NPP would do this for me.

       
    • Nobody/Anonymous

      The configuration of File association is very difficult to set. Every time, only one file type can be set..

       
      • Nobody/Anonymous

        What do you mean by "only one file type can be set"?

         
    • Nobody/Anonymous

      Congratulation to the anonymous registry handler, you worked that out very beautifully. *Thumbs up^*

      Would you share also the other extension, if you have?
      You can take it to an free hoster.

      Thanks Man.

       
    • Nobody/Anonymous

      hello threatstarter, you see the question?

       
    • Nobody/Anonymous

      Is anyone familiar with updating the registry and tried it out?
      If so please share it!
      Thanks.

       
  • No Way

    No Way - 2011-03-21

    I have to admit I agree file associations in Notepad++ is a disaster, infact I think it's a perfect example of how not to do it. Trying to add or remove many file associations in Notepad++ options is laborious and frustrating. At least if we could double click a filetype to have it add or remove would be a major improvement but still not great. the GUI as a few things which seem to have been overlooked for ages, right down to the tiny little box where you selecting the installation options.

    I've also had icon problems when making Notepad++ the default program for txt files though changing back to Notepad or anything else and the icon is fine, only way I could get it to be the default without the icon being blank is to do it manually with something like FileTypesMan, which thankfully doesn't change the description or another other than what txt files open with.

     
  • Júnior Mendonça

    For thoose who wants to see default file type on explorer, remove the default value from
    "HKEY_CLASSES_ROOT\Notepad++_file" at registry.