Most of games I install are GOG versions and the installers generate loads of unnecessary files, all have uninstallers, and if I want to uninstall, I will just delete the installation folder. I use this PowerShell command to delete these useless files, which works:
# I have confirmed deleting these files doesn't affect the functions of the games
function Remove-GOG ($game) {
Get-ChildItem -path $game -file | Where-Object {$_.fullname -match "gog.ico|goggame|support.ico|webcache|gameuxinstallhelper.dll|unins\d{3}|launch.+\.lnk|eula.txt"} | remove-item
}
However, whenever I launch such a game using the executable directly, its icon in the taskbar is a blank one, the generic icon for shortcuts whose icons are deleted.
- The executable itself contains icons, and I didn't launch the game using a shortcut.
- The executable isn't pinned to the taskbar, and the icons aren't present within:
%APPDATA%\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar
- The shortcut is the same as
launch {game_name}.lnk
and it uses agoggame-{game_id}\.(ico|dll)
icon file, which is deleted using the above PowerShell function
How can I programmatically delete the ghost shortcuts in the Registry and restore the original icons to the Taskbar shortcuts?
To resolve and manually change the icon through the slow GUI (being greeted by a file not found message first) after launching the game, I have to switch to the Desktop via:
- Alt+Tab → Right-click the Taskbar shortcut → Properties → Change Icon...
I believe the shortcut must be associated with the executable in the Registry, making the Taskbar icons use the deleted .ico
files, and whenever I run the game directly, the shortcut overwrites the Taskbar icon of the executable despite the shortcut file being deleted.
- After tediously searching Google, I have found the most relevant key to be, but have no idea if it is the key:
HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\UFH\SHC
- I want the Taskbar icon to use an icon found inside the executable itself when given the absolute path of the executable.
.lnk
shortcut, and somehow the taskbar icon uses the deleted.lnk
file.