josephspurrier / goversioninfo

Golang Microsoft Windows File Properties/Version Info and Icon Resource Generator
MIT License
836 stars 115 forks source link

Cannot specify new icon #53

Closed hanxiaohuivc closed 2 years ago

hanxiaohuivc commented 2 years ago

I have successfully set the icon for my exe, but after I replaced it with a new icon.ico file and used go generate and go build to rebuild the exe, the exe icon was still the original one. How to solve this problem? My environment is win10.

josephspurrier commented 2 years ago

It may have to do with the Windows 10 icon cache - not the library. Try the suggestion in the article and let me know: https://www.howtogeek.com/232779/how-to-rebuild-a-broken-icon-cache-in-windows-10/

hanxiaohuivc commented 2 years ago

It may have to do with the Windows 10 icon cache - not the library. Try the suggestion in the article and let me know: https://www.howtogeek.com/232779/how-to-rebuild-a-broken-icon-cache-in-windows-10/

Hello. I followed this link, but it did not solve my problem. But if the computer is turned off after several days. The windows system may update the icon. I haven't found a way to show the effect in real time. I wonder if you have any better suggestions. thanks.

josephspurrier commented 2 years ago

If you show system files - do you have a thumbs.db file in your project/app folder? If so, delete it and see if that resolves it. It doesn't sound like an app issue if leaving the computer off for a few days sometimes fixes it.

hanxiaohuivc commented 2 years ago

If you show system files - do you have a thumbs.db file in your project/app folder? If so, delete it and see if that resolves it. It doesn't sound like an app issue if leaving the computer off for a few days sometimes fixes it.

Thank you for your reply. There was a problem with my previous operation. The correct way is: I first delete the "resource.syso" and exe file, then clear the system icon cache, and finally execute go generate and go build to generate a new exe file. The script to clear the system cache is as follows (win10 system):

`taskkill /f /im explorer.exe

attrib -h -s -r "%userprofile%\AppData\Local\IconCache.db"

del /f "%userprofile%\AppData\Local\IconCache.db"

attrib /s /d -h -s -r "%userprofile%\AppData\Local\Microsoft\Windows\Explorer*"

del /f "%userprofile%\AppData\Local\Microsoft\Windows\Explorer\iconcache_16.db" del /f "%userprofile%\AppData\Local\Microsoft\Windows\Explorer\iconcache_32.db" del /f "%userprofile%\AppData\Local\Microsoft\Windows\Explorer\iconcache_48.db" del /f "%userprofile%\AppData\Local\Microsoft\Windows\Explorer\iconcache_96.db" del /f "%userprofile%\AppData\Local\Microsoft\Windows\Explorer\iconcache_256.db" del /f "%userprofile%\AppData\Local\Microsoft\Windows\Explorer\iconcache_768.db" del /f "%userprofile%\AppData\Local\Microsoft\Windows\Explorer\iconcache_1208.db" del /f "%userprofile%\AppData\Local\Microsoft\Windows\Explorer\iconcache_1920.db" del /f "%userprofile%\AppData\Local\Microsoft\Windows\Explorer\iconcache_2560.db" del /f "%userprofile%\AppData\Local\Microsoft\Windows\Explorer\iconcache_custom_stream.db" del /f "%userprofile%\AppData\Local\Microsoft\Windows\Explorer\iconcache_exif.db" del /f "%userprofile%\AppData\Local\Microsoft\Windows\Explorer\iconcache_idx.db" del /f "%userprofile%\AppData\Local\Microsoft\Windows\Explorer\iconcache_sr.db" del /f "%userprofile%\AppData\Local\Microsoft\Windows\Explorer\iconcache_wide.db" del /f "%userprofile%\AppData\Local\Microsoft\Windows\Explorer\iconcache_wide_alternate.db"

del /f "%userprofile%\AppData\Local\Microsoft\Windows\Explorer\thumbcache_16.db" del /f "%userprofile%\AppData\Local\Microsoft\Windows\Explorer\thumbcache_32.db" del /f "%userprofile%\AppData\Local\Microsoft\Windows\Explorer\thumbcache_48.db" del /f "%userprofile%\AppData\Local\Microsoft\Windows\Explorer\thumbcache_96.db" del /f "%userprofile%\AppData\Local\Microsoft\Windows\Explorer\thumbcache_768.db" del /f "%userprofile%\AppData\Local\Microsoft\Windows\Explorer\thumbcache_256.db" del /f "%userprofile%\AppData\Local\Microsoft\Windows\Explorer\thumbcache_1280.db" del /f "%userprofile%\AppData\Local\Microsoft\Windows\Explorer\thumbcache_1920.db" del /f "%userprofile%\AppData\Local\Microsoft\Windows\Explorer\thumbcache_2560.db" del /f "%userprofile%\AppData\Local\Microsoft\Windows\Explorer\thumbcache_idx.db" del /f "%userprofile%\AppData\Local\Microsoft\Windows\Explorer\thumbcache_sr.db" del /f "%userprofile%\AppData\Local\Microsoft\Windows\Explorer\thumbcache_custom_stream.db" del /f "%userprofile%\AppData\Local\Microsoft\Windows\Explorer\thumbcache_exif.db" del /f "%userprofile%\AppData\Local\Microsoft\Windows\Explorer\thumbcache_wide.db" del /f "%userprofile%\AppData\Local\Microsoft\Windows\Explorer\thumbcache_wide_alternate.db"

echo y|reg delete "HKEY_CLASSES_ROOT\Local Settings\Software\Microsoft\Windows\CurrentVersion\TrayNotify" /v IconStreams echo y|reg delete "HKEY_CLASSES_ROOT\Local Settings\Software\Microsoft\Windows\CurrentVersion\TrayNotify" /v PastIconsStream

start explorer

pause `

josephspurrier commented 2 years ago

Great, thanks for posting your solution!