<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[file associations (file types to open with npp)]]></title><description><![CDATA[<p dir="auto">I’m working with a reg file for a while,<br />
in order to create my npp associations and use it when I format/change pc/laptop etc.</p>
<p dir="auto">well, I found out recently that it doesn’t work, as expected at least,</p>
<p dir="auto">first of all, for txt files I use:</p>
<pre><code>[-HKEY_LOCAL_MACHINE\SOFTWARE\Classes\.txt]
[-HKEY_LOCAL_MACHINE\SOFTWARE\Classes\txt]
[-HKEY_CURRENT_USER\SOFTWARE\Classes\.txt]
[-HKEY_CURRENT_USER\SOFTWARE\Classes\txt]
[-HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.txt\UserChoice]
[-HKEY_CURRENT_USER\Software\Microsoft\Windows\Roaming\OpenWith\FileExts\.txt\UserChoice]
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\.txt]
"PerceivedType"="text"
@="txtfile"
"Content Type"="text/plain"
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.txt\OpenWithProgids]
"txtfile"=hex(0):
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\.txt\DefaultIcon]
@="\"D:\\Utilities\\PortableApps\\Notepad++\\notepad++.exe\",0"
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\.txt\shell\open\command]
@="\"D:\\Utilities\\PortableApps\\Notepad++\\notepad++.exe\" \"%1\""
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.txt\UserChoice]
"ProgId"="txt_auto_file"
"Hash"="q4kw7ShKh2M="
</code></pre>
<p dir="auto">I clean them all and then I re-create from scratch,</p>
<ol>
<li>do I need all of these entries?<br />
also,</li>
<li>what is this hash that is created everytime I assign npp to always open txt files? is it needed? I tried to run the above reg script on a windows 7 machine and it didn’t  work (trying to open a .txt file afterwards requested that I specify which program I want it to open with), while they work on my laptop, which is windows 8.1</li>
</ol>
]]></description><link>https://community.notepad-plus-plus.org/topic/17017/file-associations-file-types-to-open-with-npp</link><generator>RSS for Node</generator><lastBuildDate>Sun, 19 Jul 2026 16:12:02 GMT</lastBuildDate><atom:link href="https://community.notepad-plus-plus.org/topic/17017.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 29 Jan 2019 09:41:57 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to file associations (file types to open with npp) on Sun, 03 Feb 2019 07:43:22 GMT]]></title><description><![CDATA[<p dir="auto">well, thank you very much, you found the problem!</p>
<p dir="auto">which was in deleting the whole</p>
<pre><code>...\FileExts\.txt\
</code></pre>
<p dir="auto">I was able to maintain my machine code too,<br />
here is the new version (final I hope) with my associations,<br />
anyone can adjust it to his needs of course of replace HKLM to HKCU if he wants:</p>
<pre><code>https://textuploader.com/1awwn/raw
</code></pre>
]]></description><link>https://community.notepad-plus-plus.org/post/39297</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/39297</guid><dc:creator><![CDATA[patrickdrd]]></dc:creator><pubDate>Sun, 03 Feb 2019 07:43:22 GMT</pubDate></item><item><title><![CDATA[Reply to file associations (file types to open with npp) on Sat, 02 Feb 2019 17:29:57 GMT]]></title><description><![CDATA[<p dir="auto">I think you might have to delete the whole <code>...\FileExts\.txt\ </code> key , not just the <code>\UserChoice\ </code> subkey.  And don’t forget that to see the changes, you have to initiate a refresh in some manner – whether by nirsoft or windows API or logging out/in, or rebooting.</p>
<blockquote>
<p dir="auto">as you can see I’m deleting everything before the operation, so there is no txt_auto_file or anything, however that doesnt work still</p>
</blockquote>
<p dir="auto">Actually, what you just showed never mentioned <code>txt_auto_file</code>, so I cannot see that you’re deleting everything.</p>
<p dir="auto">Have you actually verified in regedit that it’s done the additions and deletions that you are expecting?</p>
<p dir="auto">From a command line,</p>
<pre><code>REG QUERY HKCU\Software\Classes\.txt /s
REG QUERY HKLM\Software\Classes\.txt /s
REG QUERY HKCU\Software\Classes\txt /s
REG QUERY HKLM\Software\Classes\txt /s
REG QUERY HKCU\Software\Classes\txt_auto_file /s
REG QUERY HKLM\Software\Classes\txt_auto_file /s
</code></pre>
<p dir="auto">Other than that, I don’t know what else to suggest.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/39254</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/39254</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Sat, 02 Feb 2019 17:29:57 GMT</pubDate></item><item><title><![CDATA[Reply to file associations (file types to open with npp) on Sat, 02 Feb 2019 07:40:00 GMT]]></title><description><![CDATA[<p dir="auto">well I’ve just tried this:<br />
[-HKEY_LOCAL_MACHINE\SOFTWARE\Classes.txt]<br />
[-HKEY_LOCAL_MACHINE\SOFTWARE\Classes\txt]<br />
[-HKEY_CURRENT_USER\SOFTWARE\Classes.txt]<br />
[-HKEY_CURRENT_USER\SOFTWARE\Classes\txt]<br />
[-HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts.txt\UserChoice]<br />
[-HKEY_CURRENT_USER\Software\Microsoft\Windows\Roaming\OpenWith\FileExts.txt\UserChoice]<br />
[-HKEY_CURRENT_USER\Software\Classes.txt]<br />
[-HKEY_CURRENT_USER\Software\Classes\txt]</p>
<pre><code>[HKEY_CURRENT_USER\Software\Classes\.txt]
@="txt"
[HKEY_CURRENT_USER\SOFTWARE\Classes\txt\DefaultIcon]
@="\"D:\\Utilities\\PortableApps\\Notepad++\\notepad++.exe\",0"
[HKEY_CURRENT_USER\Software\Classes\txt]
@="Text Document"
[HKEY_CURRENT_USER\Software\Classes\txt\shell]
@="Notepad++"
[HKEY_CURRENT_USER\Software\Classes\txt\shell\Notepad++]
@="Edit With Notepad++"
[HKEY_CURRENT_USER\Software\Classes\txt\shell\Notepad++\command]
@="\"D:\\Utilities\\PortableApps\\Notepad++\\notepad++.exe\" \"%1\""
</code></pre>
<p dir="auto">as you can see I’m deleting everything before the operation, so there is no txt_auto_file or anything, however that doesnt work still</p>
]]></description><link>https://community.notepad-plus-plus.org/post/39246</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/39246</guid><dc:creator><![CDATA[patrickdrd]]></dc:creator><pubDate>Sat, 02 Feb 2019 07:40:00 GMT</pubDate></item><item><title><![CDATA[Reply to file associations (file types to open with npp) on Fri, 01 Feb 2019 19:47:51 GMT]]></title><description><![CDATA[<p dir="auto">Further details:</p>
<p dir="auto">The hash you are mentioning, from your original post:</p>
<pre><code>[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.txt\UserChoice]
"ProgId"="txt_auto_file"
"Hash"="q4kw7ShKh2M="
</code></pre>
<p dir="auto">Is part of the <code>HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.txt</code> that I told you to delete – it will delete the .txt and everything under it, including your hash.</p>
<p dir="auto">While quoting that piece from your original post, I see what may have been going on from the start: You are telling windows that the current user has chosen the program ID (ProgID) of “txt_auto_file”.  But then you are defining the details of the file type, not under <code>txt_auto_file</code>, but under <code>txt</code> – so you were telling Windows that the user had chosen a different association for <code>.txt</code> than you were defining, so windows was still using your old “txt_auto_file” rather than the new “txt”.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/39233</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/39233</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Fri, 01 Feb 2019 19:47:51 GMT</pubDate></item><item><title><![CDATA[Reply to file associations (file types to open with npp) on Fri, 01 Feb 2019 19:40:24 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/patrickdrd" aria-label="Profile: patrickdrd">@<bdi>patrickdrd</bdi></a> ,</p>
<p dir="auto">The reg file I was talking about was</p>
<pre><code>[HKEY_CURRENT_USER\Software\Classes\.txt]
@="txt"
[HKEY_CURRENT_USER\SOFTWARE\Classes\txt\DefaultIcon]
@="\"D:\\Utilities\\PortableApps\\Notepad++\\notepad++.exe\",0"
[HKEY_CURRENT_USER\Software\Classes\txt]
@="Text Document"
[HKEY_CURRENT_USER\Software\Classes\txt\shell]
@="Notepad++"
[HKEY_CURRENT_USER\Software\Classes\txt\shell\Notepad++]
@="Eko3 Edit With Notepad++"
[HKEY_CURRENT_USER\Software\Classes\txt\shell\Notepad++\command]
@="\"D:\\Utilities\\PortableApps\\Notepad++\\notepad++.exe\" \"%1\""
</code></pre>
<p dir="auto">… which does not contain a hash.  Using that file, and the steps I described above, the association worked just fine.</p>
<p dir="auto">(<strong>edit</strong>: well, okay, <em>almost</em> that file.  I had to add the registry header line, and I converted the path to notepad++.exe to work for my setup.)</p>
]]></description><link>https://community.notepad-plus-plus.org/post/39232</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/39232</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Fri, 01 Feb 2019 19:40:24 GMT</pubDate></item><item><title><![CDATA[Reply to file associations (file types to open with npp) on Fri, 01 Feb 2019 19:33:15 GMT]]></title><description><![CDATA[<p dir="auto">no, I didn’t mean to try my method, I know that the reg works but it contains this hash,<br />
if you found a working way of setting the .txt association without the hash, please post</p>
]]></description><link>https://community.notepad-plus-plus.org/post/39231</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/39231</guid><dc:creator><![CDATA[patrickdrd]]></dc:creator><pubDate>Fri, 01 Feb 2019 19:33:15 GMT</pubDate></item><item><title><![CDATA[Reply to file associations (file types to open with npp) on Fri, 01 Feb 2019 18:32:22 GMT]]></title><description><![CDATA[<p dir="auto">So, based on my experiments, the following worked for me:</p>
<ul>
<li>If there already is a <code>HKLM\Software\Classes\.txt</code>, you have to delete it using Admin privileges</li>
<li>If there already is a <code>HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.txt</code>, delete it (shouldn’t require Admin, because it’s Current User)
<ul>
<li>I also removed any *.txt from <code>HKCU\Software\Microsoft\Windows\CurrentVersion\ApplicationAssociationToasts\</code> – I don’t know if that’s required (I don’t think so), but I had already done it, so…</li>
</ul>
</li>
<li><em>Then</em> run your .reg file shown, which will set up the <code>HKCU\Software\Classes\.txt</code></li>
<li>Then do a refresh (reboot, or logout/login, or <code>nircmd shellrefresh &amp;&amp; nircmd sysrefresh</code>)</li>
<li>When I did all that, my old association with <code>.txt</code> was gone, and it shows up using the one from your <code>.reg</code> sequence  (I actually used “DRD Text Document” as the name and “DRD Edit With Notepad++” to disambiguate from my other naming scheme)</li>
</ul>
<p dir="auto">If I then re-instate the <code>HKLM\Software\Classes\.txt</code> assocation (Admin regedit) and remove the <code>HKCU\Software\Classes\.txt</code> assoc (normal user regedit) and refresh, it goes back to using my old assocation.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/39230</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/39230</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Fri, 01 Feb 2019 18:32:22 GMT</pubDate></item><item><title><![CDATA[Reply to file associations (file types to open with npp) on Fri, 01 Feb 2019 06:57:05 GMT]]></title><description><![CDATA[<p dir="auto">well that example with .eko3 worked for me too (in 8.1),<br />
but when I try the same with .txt, e.g.:</p>
<pre><code>[HKEY_CURRENT_USER\Software\Classes\.txt]
@="txt"
[HKEY_CURRENT_USER\SOFTWARE\Classes\txt\DefaultIcon]
@="\"D:\\Utilities\\PortableApps\\Notepad++\\notepad++.exe\",0"
[HKEY_CURRENT_USER\Software\Classes\txt]
@="Text Document"
[HKEY_CURRENT_USER\Software\Classes\txt\shell]
@="Notepad++"
[HKEY_CURRENT_USER\Software\Classes\txt\shell\Notepad++]
@="Eko3 Edit With Notepad++"
[HKEY_CURRENT_USER\Software\Classes\txt\shell\Notepad++\command]
@="\"D:\\Utilities\\PortableApps\\Notepad++\\notepad++.exe\" \"%1\""
</code></pre>
<p dir="auto">it doesn’t work</p>
<p dir="auto">can you try the same <a class="plugin-mentions-user plugin-mentions-a" href="/user/peterjones" aria-label="Profile: PeterJones">@<bdi>PeterJones</bdi></a>?</p>
]]></description><link>https://community.notepad-plus-plus.org/post/39204</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/39204</guid><dc:creator><![CDATA[patrickdrd]]></dc:creator><pubDate>Fri, 01 Feb 2019 06:57:05 GMT</pubDate></item><item><title><![CDATA[Reply to file associations (file types to open with npp) on Thu, 31 Jan 2019 18:31:35 GMT]]></title><description><![CDATA[<p dir="auto">You are right: if I write to HKCR, it duplicates to HKLM, so that is an issue (of course, if you don’t have permission to write to HKLM, it won’t do that write).</p>
<p dir="auto">I just tried an experiment where I created <code>HKCU\Software\Classes\.eko2</code> (.eko was my write-to-HKCR experiment, so wanted a new extension), and pointed it to my existing <code>txtfile</code> type; when I do that and refresh environment, it associates .eko2 file extension with txtfile, and thus opens with Notepad++ when I double-click… When I look back through the registry, the <code>.eko2</code> key exists in <code>HKCU\Software\Classes</code> where I put it, and also exists as <code>HKCR\.eko2</code>, but does not exist as <code>HKLM\Software\Classes\.eko2</code>, so I believe that writing to <code>HKCU\Software\Classes\</code> is safer.</p>
<p dir="auto">As another experiment, I created <code>HKCU\Software\Classes\EkoThreeType</code> with <code>(default) = Eko palypse type 3</code>, subkey <code>shell</code>, subkey <code>Notepad++ (default)=notepad++...</code> then <code>HKCU\Software\Classes\.eko3 (default)=EkoThreeType</code>.  It also properly associated.</p>
<pre><code>[HKEY_CURRENT_USER\Software\Classes\EkoThreeType]
@="Eko palypse type 3"

[HKEY_CURRENT_USER\Software\Classes\EkoThreeType\shell]
@="Notepad++"

[HKEY_CURRENT_USER\Software\Classes\EkoThreeType\shell\Notepad++]
@="Eko3 Edit With Notepad++"

[HKEY_CURRENT_USER\Software\Classes\EkoThreeType\shell\Notepad++\command]
@="\"c:\\usr\\local\\scripts\\notepad++.bat\" \"%1\""

[HKEY_CURRENT_USER\Software\Classes\.eko3]
@="EkoThreeType"
</code></pre>
<p dir="auto">So, even using HKCU\Software\Classes, I can associate a file extension and new filetype for myself.</p>
<p dir="auto">-----<br />
PS: for refresh, i use <code>nircmd shellrefresh</code> and <code>nircmd sysrefresh</code>, using the NirSoft <a href="http://nirsoft.net/utils/nircmd.html" rel="nofollow ugc">nircmd</a> utility.  This avoids having to reboot or log in/out for every change.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/39195</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/39195</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Thu, 31 Jan 2019 18:31:35 GMT</pubDate></item><item><title><![CDATA[Reply to file associations (file types to open with npp) on Thu, 31 Jan 2019 17:37:34 GMT]]></title><description><![CDATA[<p dir="auto">Seems one of those things <strong>WE</strong> do which wasn’t initially planned by MS :-)<br />
But if you replace it under HKCR, is it set in HKLM or HKCU?<br />
If it is HKLM, then isn’t it a security issue??</p>
]]></description><link>https://community.notepad-plus-plus.org/post/39190</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/39190</guid><dc:creator><![CDATA[Eko palypse]]></dc:creator><pubDate>Thu, 31 Jan 2019 17:37:34 GMT</pubDate></item><item><title><![CDATA[Reply to file associations (file types to open with npp) on Thu, 31 Jan 2019 17:35:18 GMT]]></title><description><![CDATA[<p dir="auto">It’s worked with HKCR on every windows (I believe since NT; definitely XP, 7, and 10) for me, and I’ve never had problems with it on any machine at work or at home, where I’ve used this method for years.  When I write the one in HKCR, it’s always correctly been copied to the appropriate HKLM/HKCU locations without difficulty.</p>
<p dir="auto">(<em>edit</em>: that doesn’t mean it’s the “right” way to do it; I’ve just never had a problem with it.)</p>
]]></description><link>https://community.notepad-plus-plus.org/post/39189</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/39189</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Thu, 31 Jan 2019 17:35:18 GMT</pubDate></item><item><title><![CDATA[Reply to file associations (file types to open with npp) on Thu, 31 Jan 2019 17:28:59 GMT]]></title><description><![CDATA[<p dir="auto">But, afaik, you shouldn’t use HKEY_CLASSES_ROOT as this, itself, isn’t a persistent key.<br />
It’s just another view of keys stored in HKEY_LOCAL_MACHINE and HKEY_CURRENT_USER.<br />
I’m unsure what kind of issue would possibly rise if one corrupts HKCR.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/39186</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/39186</guid><dc:creator><![CDATA[Eko palypse]]></dc:creator><pubDate>Thu, 31 Jan 2019 17:28:59 GMT</pubDate></item><item><title><![CDATA[Reply to file associations (file types to open with npp) on Thu, 31 Jan 2019 17:17:22 GMT]]></title><description><![CDATA[<p dir="auto">With Windows 10, at least, the good old fashioned <code>HKCR\.ext (Default)=SomeAction</code> and <code>HKCR\SomeAction\command (default)=notepad++ "%1"</code> still works for me, and I thought if it worked in Win7 and works in Win10, it would work in Win8.  But I could be wrong.</p>
<p dir="auto">An example of me recently verifying that the old-style assocation works can be <a href="https://superuser.com/a/1400213/422309" rel="nofollow ugc">found on superuser</a>.  maybe it’s because the .0-.9 extensions were ones that weren’t already being interfered with using the Classes/FilesExts assocation.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/39183</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/39183</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Thu, 31 Jan 2019 17:17:22 GMT</pubDate></item><item><title><![CDATA[Reply to file associations (file types to open with npp) on Thu, 31 Jan 2019 16:47:35 GMT]]></title><description><![CDATA[<p dir="auto">:-( - although I can see why securing it might be a good choice. Too bad - at least I learnt something new. :-)</p>
]]></description><link>https://community.notepad-plus-plus.org/post/39179</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/39179</guid><dc:creator><![CDATA[Eko palypse]]></dc:creator><pubDate>Thu, 31 Jan 2019 16:47:35 GMT</pubDate></item><item><title><![CDATA[Reply to file associations (file types to open with npp) on Thu, 31 Jan 2019 08:35:21 GMT]]></title><description><![CDATA[<p dir="auto">ok I’ve found it,<br />
<a href="https://stackoverflow.com/questions/17946282/whats-the-hash-in-hkcu-software-microsoft-windows-currentversion-explorer-filee" rel="nofollow ugc">https://stackoverflow.com/questions/17946282/whats-the-hash-in-hkcu-software-microsoft-windows-currentversion-explorer-filee</a></p>
]]></description><link>https://community.notepad-plus-plus.org/post/39167</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/39167</guid><dc:creator><![CDATA[patrickdrd]]></dc:creator><pubDate>Thu, 31 Jan 2019 08:35:21 GMT</pubDate></item><item><title><![CDATA[Reply to file associations (file types to open with npp) on Thu, 31 Jan 2019 06:49:55 GMT]]></title><description><![CDATA[<p dir="auto">I think I fixed it to work in windows 8.1 and windows 7:</p>
<pre><code>https://textuploader.com/1awwn/raw
</code></pre>
<p dir="auto">I found out that some files need the “hash” in registry which is awkward,<br />
because I don’t know if it will work in another pc,<br />
but I don’t have another 8.1,<br />
so if anyone wants to test it</p>
]]></description><link>https://community.notepad-plus-plus.org/post/39165</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/39165</guid><dc:creator><![CDATA[patrickdrd]]></dc:creator><pubDate>Thu, 31 Jan 2019 06:49:55 GMT</pubDate></item><item><title><![CDATA[Reply to file associations (file types to open with npp) on Thu, 31 Jan 2019 06:46:13 GMT]]></title><description><![CDATA[<p dir="auto">no, it doesn’t,<br />
e.g. I deleted already registered txt file with</p>
<pre><code>[-HKEY_LOCAL_MACHINE\SOFTWARE\Classes\.txt]
[-HKEY_LOCAL_MACHINE\SOFTWARE\Classes\txt]
[-HKEY_CURRENT_USER\SOFTWARE\Classes\.txt]
[-HKEY_CURRENT_USER\SOFTWARE\Classes\txt]
[-HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.txt\UserChoice]
[-HKEY_CURRENT_USER\Software\Microsoft\Windows\Roaming\OpenWith\FileExts\.txt\UserChoice]
</code></pre>
<p dir="auto">and tried yours and no error was shown but when tried to open .txt file it asked what I wanted to open it with</p>
]]></description><link>https://community.notepad-plus-plus.org/post/39164</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/39164</guid><dc:creator><![CDATA[patrickdrd]]></dc:creator><pubDate>Thu, 31 Jan 2019 06:46:13 GMT</pubDate></item><item><title><![CDATA[Reply to file associations (file types to open with npp) on Wed, 30 Jan 2019 23:32:20 GMT]]></title><description><![CDATA[<p dir="auto">Hopefully this does what you are looking for.<br />
The problem with the icon cache reload is still not solved.</p>
<pre><code>import ctypes
import ctypes.wintypes as wintypes
from Npp import notepad, MESSAGEBOXFLAGS


# modify this two variables to your needs
# ------------------------------------------------------------------------------------------------------------------------

NPP_FULL_PATH = u'D:\\PortableApps\\Npp\\notepad++.exe'
FILE_EXT = ['.txt','.xml']

# ------------------------------------------------------------------------------------------------------------------------


shell32 = ctypes.WinDLL('shell32')
advapi32 = ctypes.WinDLL('advapi32')

SHCNE_ASSOCCHANGED = 0x08000000
SHCNF_IDLIST = 0

HKEY_CURRENT_USER = -2147483647
HKEY_LOCAL_MACHINE = -2147483646
KEY_ALL_ACCESS = 0xf003f
REG_SZ = 1
ERROR_SUCCESS = 0x0

SUB_KEY = u'Software\\Classes\\{}'
NPPNAME = u'Notepad++_file'
DOCTYP = u'Notepad++ Document'
NPP_ICON = u'"{}",0'.format(NPP_FULL_PATH)
NPP_COMMAND = u'"{}" "%1"'.format(NPP_FULL_PATH)


def set_reg_value(root_key, value):
    try:
        result = advapi32.RegSetValueExW(root_key,
                                         None,
                                         0,
                                         REG_SZ,
                                         value,
                                         len(value) * ctypes.sizeof(wintypes.c_wchar))

        if result == ERROR_SUCCESS:
            print('successfully set {}'.format(value))
        else:
            notepad.messageBox('Aborting as error {} occured'.format(result), 'ERROR', MESSAGEBOXFLAGS.ICONERROR)
    except Exception as e:
        raise IOError('{}'.format(e))
    finally:
        advapi32.RegCloseKey(root_key)


def create_reg_entries(root_key, sub_key):
    try:
        phkResult = wintypes.HKEY()
        dwDisp = wintypes.DWORD()
        result = advapi32.RegCreateKeyExW(root_key,
                                          sub_key,
                                          0,
                                          None,
                                          0,
                                          KEY_ALL_ACCESS,
                                          None,
                                          ctypes.byref(phkResult),
                                          ctypes.byref(dwDisp)
                                          )
        if result == ERROR_SUCCESS:
            if dwDisp.value in [1, 2]:
                print '\nKey {} has been {}'.format(sub_key, 'created' if dwDisp == 1 else 'opened')
            else:
                notepad.messageBox('Unexpected disposition value received:{}'.format(dwDisp), 'WARNING', MESSAGEBOXFLAGS.ICONWARNING)
    except Exception as e:
        advapi32.RegCloseKey(root_key)
        raise IOError('{}'.format(e))

    return phkResult


def create_npp_link(root_key):
    _key = create_reg_entries(root_key, SUB_KEY.format(NPPNAME))
    set_reg_value(_key, DOCTYP)
    _key = create_reg_entries(root_key, SUB_KEY.format(u'Notepad++_file\\DefaultIcon'))
    set_reg_value(_key, NPP_ICON)
    _key = create_reg_entries(root_key, SUB_KEY.format(u'Notepad++_file\\shell\\open\\command'))
    set_reg_value(_key, NPP_COMMAND)
    return True


def register_extensions(root_key):
    for extension in FILE_EXT:
        _key = create_reg_entries(root_key, SUB_KEY.format(extension))
        set_reg_value(_key, NPPNAME)
    return True


def main():
    result = notepad.messageBox(('YES for USER only\n\n'
                                 'NO for MACHINE\n\n'
                                 'CANCEL to abort'), 'FileExtension Registration', 3)

    if result == MESSAGEBOXFLAGS.RESULTYES:
        _HKEY = HKEY_CURRENT_USER
    elif result == MESSAGEBOXFLAGS.RESULTNO:
        _HKEY = HKEY_LOCAL_MACHINE
    else:
        return

    if create_npp_link(_HKEY):
        if register_extensions(_HKEY):
            result = notepad.messageBox('Should the system be informed about the changes?', 'Inform System', 4)
            if result == MESSAGEBOXFLAGS.RESULTYES:
                shell32.SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, None, None)
    else:
        notepad.messageBox('Unable to open or create Notepad++_file key', 'ERROR', MESSAGEBOXFLAGS.ICONERROR)

main()
</code></pre>
]]></description><link>https://community.notepad-plus-plus.org/post/39154</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/39154</guid><dc:creator><![CDATA[Eko palypse]]></dc:creator><pubDate>Wed, 30 Jan 2019 23:32:20 GMT</pubDate></item><item><title><![CDATA[Reply to file associations (file types to open with npp) on Wed, 30 Jan 2019 12:31:11 GMT]]></title><description><![CDATA[<p dir="auto">don’t worry, I’m not in a hurry,<br />
this thread will be active for a while,<br />
I’ll be waiting for SalviaSage’s reply too</p>
<p dir="auto">as for the your question, yes, silent is fine,<br />
if I was writing the script,<br />
I would choose machine silently too</p>
]]></description><link>https://community.notepad-plus-plus.org/post/39133</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/39133</guid><dc:creator><![CDATA[patrickdrd]]></dc:creator><pubDate>Wed, 30 Jan 2019 12:31:11 GMT</pubDate></item><item><title><![CDATA[Reply to file associations (file types to open with npp) on Wed, 30 Jan 2019 12:21:00 GMT]]></title><description><![CDATA[<p dir="auto">Ok, I will try to come up with a solution later this day.<br />
Lunch break if over.</p>
<p dir="auto">While thinking about the dialog to ask for confirmation about<br />
creating the Notepad++_file link - does it really makes sense?<br />
I mean, if one runs the script the idea is to have the extensions<br />
registered and this means you <strong>need to</strong> have the key.<br />
I guess silently setting the key is ok.</p>
<p dir="auto">Other question to everyone reading this,<br />
Does someone know a way to refresh the icon cache?<br />
Currently, if you run the script and, let’s say you want to register<br />
.xml to be opened with npp, you still see the previous icon until<br />
you logon/logoff.<br />
It would be nice if I could force to reload the icon cache so that the<br />
npp icon is shown. I haven’t found any good side describing what<br />
needs to be done yet.</p>
<p dir="auto">Have to go back to work :-)</p>
]]></description><link>https://community.notepad-plus-plus.org/post/39132</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/39132</guid><dc:creator><![CDATA[Eko palypse]]></dc:creator><pubDate>Wed, 30 Jan 2019 12:21:00 GMT</pubDate></item><item><title><![CDATA[Reply to file associations (file types to open with npp) on Wed, 30 Jan 2019 12:13:08 GMT]]></title><description><![CDATA[<p dir="auto">that’s what I meant too, within the script is fine,<br />
running the script once every time a new machine is setup is fine as well of course</p>
]]></description><link>https://community.notepad-plus-plus.org/post/39131</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/39131</guid><dc:creator><![CDATA[patrickdrd]]></dc:creator><pubDate>Wed, 30 Jan 2019 12:13:08 GMT</pubDate></item><item><title><![CDATA[Reply to file associations (file types to open with npp) on Wed, 30 Jan 2019 12:09:50 GMT]]></title><description><![CDATA[<p dir="auto">Of course ;-) - that was what I meant.<br />
Doing everything within the script.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/39130</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/39130</guid><dc:creator><![CDATA[Eko palypse]]></dc:creator><pubDate>Wed, 30 Jan 2019 12:09:50 GMT</pubDate></item><item><title><![CDATA[Reply to file associations (file types to open with npp) on Wed, 30 Jan 2019 12:06:38 GMT]]></title><description><![CDATA[<p dir="auto">no, can’t it be set inside the script like in a constant variable?</p>
]]></description><link>https://community.notepad-plus-plus.org/post/39129</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/39129</guid><dc:creator><![CDATA[patrickdrd]]></dc:creator><pubDate>Wed, 30 Jan 2019 12:06:38 GMT</pubDate></item><item><title><![CDATA[Reply to file associations (file types to open with npp) on Wed, 30 Jan 2019 11:58:08 GMT]]></title><description><![CDATA[<p dir="auto">I’ve opened the reg files but I didn’t understand what you trying to ask.<br />
So what would you suppose? Making a workflow like</p>
<p dir="auto">A.)<br />
Check if Notepad++_file link is found<br />
if found, run the script like it is now<br />
if not found, open a dialog and asking if such a key should be created?<br />
or<br />
B.)<br />
something else in mind?</p>
]]></description><link>https://community.notepad-plus-plus.org/post/39128</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/39128</guid><dc:creator><![CDATA[Eko palypse]]></dc:creator><pubDate>Wed, 30 Jan 2019 11:58:08 GMT</pubDate></item></channel></rss>