Extract shortcut icon path without expansion

106 Views Asked by At

I can use this to extract the icon path of a LNK file in $path

$WshShell = New-Object -ComObject WScript.Shell
$shortcut = $WshShell.CreateShortcut($Path)
$iconPath = $shortcut.IconLocation -replace ',\d$', $Null

but the result is expanded. What I see in the LNK file properties for Edge is %ProgramFiles(x86)%\Microsoft\Edge\Application\msedge.exe but what the code produces is C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe I am gathering data, on Autodesk products actually, for use later in replacing their crappy icons. So I would really prefer to keep and store the EV and then expand it myself on each machine, so on the off chance of a machine with a different path things don't break. But so far I can't find a way, programmatically, to get at the icon path without the expansion. Am I missing something, or am I out of luck?

0

There are 0 best solutions below