Shortcut Icon Search doesn't look at fully qualified path #8690

Closed
opened 2026-01-31 01:35:38 +00:00 by claunia · 1 comment
Owner

Originally created by @malxau on GitHub (May 30, 2020).

Environment

10.0.19041

Steps to reproduce

  1. Create a shortcut to a fully qualified command line executable, as in C:\Path\To\Thing.exe
  2. Explorer will default to consume the first icon from C:\Path\To\Thing.exe and display that as the shortcut icon.
  3. Execute the shortcut, and conhost will get a default icon.

Expected behavior

The icon in the conhost window will be the same one explorer found, being the first icon in the executable.

Actual behavior

When executing the shortcut, conhost.exe will enter SystemConfigurationProvider::GetSettingsFromLink with pwszAppName of "Thing.exe", call ShortcutSerialization::s_GetLinkValues to find if there's an explicit icon reference in the shortcut (there isn't), then it will call SearchPathW on "Thing.exe" to find any instance of it in %PATH%, then call PathFileExists on the shortcut title "Thing". It will never look at the original "C:\Path\To\Thing.exe", and will end up with a default icon. Note that the title value is changed in this function; on entry it is the path to the shortcut (not the target of the shortcut) and it is updated to contain the title field contained within the shortcut before calling PathFileExists.

It looks to me like s_GetLinkValues should also try to return the shortcut target (IShellLink::GetPath), and this value should be used in preference to SearchPathW. SearchPathW is really a fallback in case of a shortcut that contains a file name without a path.

Edit: Note that SearchPathW will search the current directory, so if the working directory in the shortcut (IShellLink::GetWorkingDirectory) is the parent directory of the executable, the icon will be found by conhost. This is the default behavior when creating a shortcut through the right click, New Shortcut menu in Explorer, but the working directory can be edited later without affecting the repro. Ie., Explorer won't explicitly set the icon location without the user selecting an icon.

Originally created by @malxau on GitHub (May 30, 2020). <!-- 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨 I ACKNOWLEDGE THE FOLLOWING BEFORE PROCEEDING: 1. If I delete this entire template and go my own path, the core team may close my issue without further explanation or engagement. 2. If I list multiple bugs/concerns in this one issue, the core team may close my issue without further explanation or engagement. 3. If I write an issue that has many duplicates, the core team may close my issue without further explanation or engagement (and without necessarily spending time to find the exact duplicate ID number). 4. If I leave the title incomplete when filing the issue, the core team may close my issue without further explanation or engagement. 5. If I file something completely blank in the body, the core team may close my issue without further explanation or engagement. All good? Then proceed! --> <!-- This bug tracker is monitored by Windows Terminal development team and other technical folks. **Important: When reporting BSODs or security issues, DO NOT attach memory dumps, logs, or traces to Github issues**. Instead, send dumps/traces to secure@microsoft.com, referencing this GitHub issue. If this is an application crash, please also provide a Feedback Hub submission link so we can find your diagnostic data on the backend. Use the category "Apps > Windows Terminal (Preview)" and choose "Share My Feedback" after submission to get the link. Please use this form and describe your issue, concisely but precisely, with as much detail as possible. --> # Environment 10.0.19041 # Steps to reproduce 1. Create a shortcut to a fully qualified command line executable, as in C:\Path\To\Thing.exe 2. Explorer will default to consume the first icon from C:\Path\To\Thing.exe and display that as the shortcut icon. 3. Execute the shortcut, and conhost will get a default icon. # Expected behavior The icon in the conhost window will be the same one explorer found, being the first icon in the executable. # Actual behavior When executing the shortcut, conhost.exe will enter SystemConfigurationProvider::GetSettingsFromLink with pwszAppName of "Thing.exe", call ShortcutSerialization::s_GetLinkValues to find if there's an explicit icon reference in the shortcut (there isn't), then it will call SearchPathW on "Thing.exe" to find any instance of it in %PATH%, then call PathFileExists on the shortcut title "Thing". It will never look at the original "C:\Path\To\Thing.exe", and will end up with a default icon. Note that the title value is changed in this function; on entry it is the path to the shortcut (not the target of the shortcut) and it is updated to contain the title field contained within the shortcut before calling PathFileExists. It looks to me like s_GetLinkValues should also try to return the shortcut target (IShellLink::GetPath), and this value should be used in preference to SearchPathW. SearchPathW is really a fallback in case of a shortcut that contains a file name without a path. Edit: Note that SearchPathW will search the current directory, so if the working directory in the shortcut (IShellLink::GetWorkingDirectory) is the parent directory of the executable, the icon will be found by conhost. This is the default behavior when creating a shortcut through the right click, New Shortcut menu in Explorer, but the working directory can be edited later without affecting the repro. Ie., Explorer won't explicitly set the icon location without the user selecting an icon.
claunia added the Product-ConhostResolution-Fix-CommittedArea-SettingsIssue-Task labels 2026-01-31 01:35:39 +00:00
Author
Owner

@ghost commented on GitHub (Jun 18, 2020):

:tada:This issue was addressed in #6277, which has now been successfully released as Windows Terminal Preview v1.1.1671.0.🎉

Handy links:

@ghost commented on GitHub (Jun 18, 2020): :tada:This issue was addressed in #6277, which has now been successfully released as `Windows Terminal Preview v1.1.1671.0`.:tada: Handy links: * [Release Notes](https://github.com/microsoft/terminal/releases/tag/v1.1.1671.0) * [Store Download](https://www.microsoft.com/store/apps/9n0dx20hk701?cid=storebadge&ocid=badge)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#8690