RegIcons 0.1 - Customize file type icons through Xyplorer

Discuss and share scripts and script files...
40k
Posts: 234
Joined: 09 Dec 2011 21:25

RegIcons 0.1 - Customize file type icons through Xyplorer

Post by 40k »

RegIcons 0.1 - Customize file type icons through Xyplorer
RegIcons.xys
(1012 Bytes) Downloaded 142 times
Pastebin link to RegIcons.xys

This script allows you to change the icon Windows will use for a given file type.
Below is a step-by-step slideshow of how this works.

A few warnings:
1. Modifying the windows registry can create some undesirable side-effects. Including killing your current Windows install. This script will never, ever, modify the registry by itself. It creates .reg files that contain registry modification instructions but does not execute these files. The user is always required to execute these files themselves. Ideally after inspecting their content using Notepad or something similar.
2. This script is mainly intended to be used in conjunction with Xy's Portable File Associations. Attempting to modify the icon of a an established file type (For example .txt, .dll, ...) will work but as a side-effect all predating associations are also deleted. If you had programs that have written to the file type keys in the registry their data will be lost. This is usually not a problem considering only keys relevant to file type icons are deleted.
3. Always, Always, Always inspect the content of any .reg file created by this script before execution. I recommend doing a test run in a virtual machine first.

Code: Select all

1. I like portable applications. As a result I don't have many file type associations. Instead I use Xy's Portable File Associations. Unfortunately this also leaves me with a lot of blank icons as I don't allow many programs to write code to my registry 
Image

Code: Select all

2. After launching the script a dialog will ask you which file types you would like to change the icon for. You can type as many file types as you like all separated by a comma, 
Image

Code: Select all

3. Next a dialog will ask you to select the icon you want to see for your file types. Many programs have .ico files but if you select a .exe the script will use the icon from that executable.
Image

Code: Select all

4. A RegIcons.reg file will appear in your <xypath>\Data\Scripts folder. Windows Registry Editor uses .reg files to allow users to spread changes to the registry of a computer over many system.
Image

Code: Select all

5. A .reg file contains simple text and can be read using Notepad
Image

Code: Select all

6. Once you have inspected the .reg file you can make the changes to your registry by executing the file (double-click). A confirmation dialog appears asking you if you understand what you are doing.
Image

Code: Select all

7.%20And%20there%20you%20go!
Image
I develop scripts that integrate media functionality into Xyplorer.
Hash - Twitch.tv in VLC (NEW 2.0!) - FFmpeg GUI - Youtube downloading
XYplorer for Linux! Tutorial

FluxTorpedoe
Posts: 855
Joined: 05 Oct 2011 13:15

Re: RegIcons 0.1 - Customize file type icons through Xyplore

Post by FluxTorpedoe »

Great idea!
Soon, with enhanced PFA + custom icons, XY portability will rule everything! :twisted:

A suggestion: it sounds a bit risky to remove potential existing associations... One could keep them when defined (even if not valid) and only change the icons by replacing the foreach with e.g.:

Code: Select all

 foreach ($Ext, $Exts, ","){
  //read entries
  $RegLog = "%temp%\__RegIcons-TMP__.ini";
  run """regedit"" /E /S ""$RegLog"" ""HKEY_CLASSES_ROOT\.$Ext""", , 2;
  $DefaultApp = getkey("@", "HKEY_CLASSES_ROOT\.$Ext", "$RegLog");
  delete 0, 0, "$RegLog";

  //write new entries
  $MediaType = ($DefaultApp)? $DefaultApp : ".$Ext";
  writefile ($g_RegPath, "[HKEY_CLASSES_ROOT\$MediaType\DefaultIcon]<crlf>", "a", );
  writefile ($g_RegPath, "@=".quote($Icon, "0")."<crlf 2>", "a", );
 }
Just an idea,
but it felt safer somehow... ;)

EDIT: Cleaned code
Note: the starting if (exists ($g_RegPath))... seems problematic

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: RegIcons 0.1 - Customize file type icons through Xyplore

Post by highend »

Please don't do this at home... or if you do it, you should be the one and only user (no other user accounts).

HKEY_CLASSES_ROOT is just a combined view of
HKEY_LOCAL_MACHINE\Software\Classes and
HKEY_CURRENT_USER\Software\Classes

If you try do delete an entry in HKEY_CLASSES_ROOT and it doesn't exist (yet) in
HKEY_CURRENT_USER\Software\Classes
it will DELETE the entry in HKEY_LOCAL_MACHINE\Software\Classes effectively destroying
this association for all (other) user accounts on the same machine!
Apart from that you must have the necessary permissions to do that (a normal user account has
no write access to HKEY_LOCAL_MACHINE) on Vista+.

Don't try to mess with HKEY_CLASSES_ROOT it's not recommended by Microsoft.

Just manipulate HKEY_CURRENT_USER\Software\Classes entries if you want to be on the safe side.

Imho "portable icon associations" should only be handled by XYplorer itself (Don could support this
in the future if he thinks it will be a nice addition), manipulating registry entries is
a.) Error prone
b.) Not portable at all

Just my 2 cents ;)
One of my scripts helped you out? Please donate via Paypal

FluxTorpedoe
Posts: 855
Joined: 05 Oct 2011 13:15

Re: RegIcons 0.1 - Customize file type icons through Xyplore

Post by FluxTorpedoe »

[OT]
highend wrote:manipulating registry entries
will wake up Godzilla! :twisted:
Proof (apart from the photo on XY's forum...):
If you look at your number of posts upside-down, you'll see the number of the Beast... :twisted: :twisted: :twisted:
Sorry, couldn't help it. :biggrin: 8)

40k
Posts: 234
Joined: 09 Dec 2011 21:25

Re: RegIcons 0.1 - Customize file type icons through Xyplore

Post by 40k »

FluxTorpedoe wrote:[OT]
highend wrote:manipulating registry entries
will wake up Godzilla! :twisted:
Proof (apart from the photo on XY's forum...):
If you look at your number of posts upside-down, you'll see the number of the Beast... :twisted: :twisted: :twisted:
Sorry, couldn't help it. :biggrin: 8)
Haha thanks for all the feedback guys! :)

It seems I may have poked the hornet's nest with this one. Thank you for your contributions to the code FluxTorpedoe. It does seem more prudent to work with a finer brush so to speak when deleting stuff in the registry. I will see how I can implement your ideas.

Highend, as usual thank you for throwing some light on this. I based my code on stuff I found on Google. As a result I was not aware that ROOT was actually a symlink repository. I will have to investigate this further. However I do not agree with your sentiment that icon association should be handled by Xyplorer natively. Furthermore I don't claim that my script returns portable file icons. It changes values in the registry and as such by its' very nature it can not be portable.
I develop scripts that integrate media functionality into Xyplorer.
Hash - Twitch.tv in VLC (NEW 2.0!) - FFmpeg GUI - Youtube downloading
XYplorer for Linux! Tutorial

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: RegIcons 0.1 - Customize file type icons through Xyplore

Post by highend »

However I do not agree with your sentiment that icon association should be handled by Xyplorer natively.
For portable icon associations this would be the only way (and a great one, too).
One of my scripts helped you out? Please donate via Paypal

40k
Posts: 234
Joined: 09 Dec 2011 21:25

Re: RegIcons 0.1 - Customize file type icons through Xyplore

Post by 40k »

highend wrote:
However I do not agree with your sentiment that icon association should be handled by Xyplorer natively.
For portable icon associations this would be the only way (and a great one, too).
Not sure how it would work considering you need to modify the registry. Perhaps with permanent silent back-ups by Xy? I don't see it happening though but Don is always welcome to come in here and shed some light. :)
I develop scripts that integrate media functionality into Xyplorer.
Hash - Twitch.tv in VLC (NEW 2.0!) - FFmpeg GUI - Youtube downloading
XYplorer for Linux! Tutorial

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: RegIcons 0.1 - Customize file type icons through Xyplore

Post by highend »

He doesn't need the registry to show icons for specific file extensions. He could "just" build his own cache of icons from a user configurable list of associations and use that one instead.

How much work that is? Don't know, I wouldn't call me a programmer ;)
One of my scripts helped you out? Please donate via Paypal

admin
Site Admin
Posts: 60357
Joined: 22 May 2004 16:48
Location: Win8.1 @100%, Win10 @100%
Contact:

Re: RegIcons 0.1 - Customize file type icons through Xyplore

Post by admin »

Yes, I could do it (and I think it would be fast enough to be hardly notable). Apparently there is some demand for portable icons?

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: RegIcons 0.1 - Customize file type icons through Xyplore

Post by highend »

Apparently there is some demand for portable icons?
Mhh.. YES :)

+500^^
One of my scripts helped you out? Please donate via Paypal

40k
Posts: 234
Joined: 09 Dec 2011 21:25

Re: RegIcons 0.1 - Customize file type icons through Xyplore

Post by 40k »

admin wrote:Yes, I could do it (and I think it would be fast enough to be hardly notable). Apparently there is some demand for portable icons?
No!, Find your own damn projects to work on!

Just kidding of course :biggrin:
I develop scripts that integrate media functionality into Xyplorer.
Hash - Twitch.tv in VLC (NEW 2.0!) - FFmpeg GUI - Youtube downloading
XYplorer for Linux! Tutorial

Enternal
Posts: 1174
Joined: 10 Jan 2012 18:26

Re: RegIcons 0.1 - Customize file type icons through Xyplore

Post by Enternal »

*raises hand
YES!

FluxTorpedoe
Posts: 855
Joined: 05 Oct 2011 13:15

Re: RegIcons 0.1 - Customize file type icons through Xyplore

Post by FluxTorpedoe »

Well, if it's not too much work... :whistle:
(though not a high priority for me)

@highend
Congrats on your 1000th post ;)

binocular222
Posts: 1416
Joined: 04 Nov 2008 05:35
Location: Hanoi, Vietnam

Re: RegIcons 0.1 - Customize file type icons through Xyplore

Post by binocular222 »

Vote yes.
Many times, windows associate 1 program but PFA open with another one, so, I need a portable icon association that truly reflect what program will lauch.
I'm a casual coder using AHK language. All of my xys scripts:
http://www.xyplorer.com/xyfc/viewtopic. ... 243#p82488

Flora_RMC
Posts: 279
Joined: 28 Dec 2012 09:50

Re: RegIcons 0.1 - Customize file type icons through Xyplore

Post by Flora_RMC »

admin wrote:Yes, I could do it. Apparently there is some demand for portable icons?
Oh yes, please. I would really love it. :D
Currently (Win7) you can only use this script or FileTypesMan, but both change the registry. If XY could handle custom icons without modify the registry, it would be awesome! :mrgreen:

Post Reply