ramdany7 / RightClick-Folder-Icon-Tools

Adds “Folder Icon Tools” to the Windows Explorer context menu. Automatically edits images, generates, converts, and applies images as folder icons.
MIT License
64 stars 7 forks source link

Cache refresh required after updating folder to a different image (to avoid return to default manila). #15

Open DMacMakes opened 3 weeks ago

DMacMakes commented 3 weeks ago

Thanks for the updates since a year ago, when I last checked in :D

Reproducing the issue:

  1. I successfully changed a folder (c:\games) to a new, custome icon (using template windows 11 A and png), which IIRC required calling Activate Icon to get going.
  2. I then tried it again on the same folder, again right clicking the icon choosing "Change Folder Icon", before dragging in a different png. It happily created the new ico and did it's work on the ini file and folder.
  3. The icon on "c:\games" changed from my first custom folder (1) back to the Win10 default, yellowish manila folder. I hit refresh a few times, going in and out of the folder, but it remained default manila.
  4. I right clicked again, clicked "Refresh Icon Cache (Without Restart), and was able to see my new custom folder (2).

Request/Potential Solution: Would it be possible to call Refresh Cache by default, when a folder icon is changed? Or, just for ones that were already activated and customised previously, if that's more appropriate? If there's a reason that's too heavy a default for various setups (maybe Win11 doesn't require it?), could there be a preference/checkbox I could set so it becomes a users personal default?

System: OS: Windows 10, 22H2, Build 19045.5011

ramdany7 commented 3 weeks ago

Hi, welcome back! :D Now it finally passed the VirusTotal checks. The issue resolved itself without needing to modify the part of the script that I thought would be suspicious. Though, I haven’t posted a release for this version yet. SCR_2024-11-07_17 08_28



About this issue. When you change a folder icon, it sometimes updates immediately, but often it doesn't. You might need to wait around 30-40 seconds and then manually refresh it using "Refresh Icon Cache (Without Restart)." Alternatively, if you use the "restart explorer" method, the icon will change immediately without needing to wait.

What does "Refresh Icon Cache" do?

  1. Removes the "Read Only" properties on the folder.
  2. Renames "desktop.ini" to "DESTOP INI"
  3. Renames it back to "desktop.ini"
  4. Reapplies the "Read Only" properties to the folder.

When generating/changing a folder icon, the process is similar:

  1. Removes the "Read Only" properties on the folder.
  2. Creates and writes to "Desktop.ini"
  3. Renames it to "desktop.ini.temp"
  4. Renames it back to "desktop.ini"
  5. Adds "Read Only" properties to the folder.

So, it actually already did what "Refresh Icon Cache" does. In my experience, while it works sometimes, more often it doesn’t. This has been a persistent issue; as it appears that Explorer doesn't always recognize the change immediately.

I've searched for solutions on "how to make folder icon changes update instantly," and I did find some useful hints, such as this Stack Overflow post and this recent discussion on VBForums. However, I haven’t yet found a method I can apply to this project, as I don't have knowledge in VBScript, C, C++, or any language other than windows batch script.

DMacMakes commented 3 weeks ago

Thanks for the very thorough answer 🙏. You've done some pretty flash work with batch scripts and calls to ImageMagick!

Hopefully over the Dec/Jan holidays I'll get a chamce to look into how the cache/icons can be refreshed in C++, and maybe make a little exe or dll. The refresh problem seems amazingly iffy - even before you start trying to change folders on mapped/network mounted drives 😂

ramdany7 commented 3 weeks ago

That's awesome! 😀 It’s a tricky problem that’s been hard for me to solve. Definitely let me know if you make any progress; I'd love to test it out!