1.17 Standard Shortcuts/Advertised Shortcuts https://scz.617.cn/windows/202109091619.txt Q: 大多数Windows快捷方式的右键属性中可以看到真实目标程序,但有些快捷方式右键 属性其目标栏是灰掉的,不可编辑,也看不出真实目标程序,比如"BinDiff 7"安装 后的快捷方式就是这样。如何查看后一种情形的真实目标程序? A: -------------------------------------------------------------------------- Advertised shortcuts vs. non-advertised shortcuts in windows setup project - Drazen Bjelovuk [2012-08-02] https://stackoverflow.com/questions/11776023/advertised-shortcuts-vs-non-advertised-shortcuts-in-windows-setup-project About Windows Installer Shortcuts - [2009-01-20] https://community.broadcom.com/symantecenterprise/communities/community-home/librarydocuments/viewdocument?DocumentKey=8f14fb42-c273-4a1c-8f49-11ae9dc08f9e&CommunityKey=41d8253b-a238-4563-8718-ed7623beafbc&tab=librarydocuments Use PowerShell to Find an Advertised Shortcut Target - Kae [2020-06-03] https://www.alkanesolutions.co.uk/2020/06/03/use-powershell-to-find-an-advertised-shortcut-target/ -------------------------------------------------------------------------- 有两种快捷方式,一种是普通快捷方式,另一种叫"Advertised Shortcuts",后者经 常为"Windows Installer"所用。 A non-advertised shortcut (Standard Shortcuts) is a standard windows shortcut. If you right-click it you will see the target field points to the executable that will be launched. If, for whatever reason, this executable is missing the application will simply fail. An advertised shortcut (Windows Installer Shortcuts) is a technology specific to Windows Installer. If you right-click an advertised shortcut the target field will be greyed out. An advertised install only puts down what we call the application interfaces. An application interface is any way to start the application. This could be a shortcut, file extension or COM interface. A shortcut created with advertising is a file descriptor, which points to the location where the setup for the application is. As a result, the shortcut properties are disabled so they cannot be edited. -------------------------------------------------------------------------- function GetAdvertisedShortcut { param( [string]$lnkpath ) $ComponentPath = "" if ( $lnkpath -ne $null -and ( test-path $lnkpath ) ) { $wi = New-Object -ComObject WindowsInstaller.Installer # # 结尾的(号不能放到新行去 # $ShortcutTarget = $wi.GetType().InvokeMember( "ShortcutTarget", "GetProperty", $null, $wi, $lnkpath ) $ProductCode = $ShortcutTarget.GetType().InvokeMember( "StringData", "GetProperty", $null, $ShortcutTarget, 1 ) $ComponentCode = $ShortcutTarget.GetType().InvokeMember( "StringData", "GetProperty", $null, $ShortcutTarget, 3 ) $ComponentPath = $wi.GetType().InvokeMember( "ComponentPath", "GetProperty", $null, $wi, @( $ProductCode, $ComponentCode ) ) } return $ComponentPath } $lnkpath = GetAdvertisedShortcut $args[0] Write-Output( $lnkpath ) -------------------------------------------------------------------------- $ powershell -ExecutionPolicy ByPass -File ReadAdvertisedShortcut.ps1 "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\BinDiff\BinDiff.lnk" C:\Program Files\BinDiff\bin\bindiff.exe