We create an shortcut in the start menu of windows and for that shortcut we want to apply the icon of the target file. The target file is an help file of Help & Manual (Suffix is .chm). We tried the following code:
var lPath = @"C:\ProgramData\Microsoft\Windows\Start Menu\Programs\ProductName\Help.lnk";
var lTargetPath = @"C:\Program Files\ManufacturerName\ProductName\Help.chm";
WshShell lWshShell = new WshShell();
IWshShortcut lShortcut = (IWshShortcut)lWshShell.CreateShortcut(lPath);
lShortcut.WorkingDirectory = lPath;
lShortcut.TargetPath = lTargetPath;
lShortcut.IconLocation = lTargetPath; // <-- I want to apply the same icon as the target file here.
The target .chm file has the followin icon:
When we execute this code, the shortcut in the start menu looks like the following:
How can we automatically apply the icon of the target file?
NOTE: When I create an shortcut via WIX using the same paths, then the icon will be applied to the shortcut.