我有一个 PowerShell 脚本,可以在登录时创建网络位置的快捷方式。不幸的是,它使用的是旧的低分辨率图标。这无论如何都不是什么大问题,但我想在更高版本的 Windows 中使用更新的图标。
这是创建快捷方式的函数的相关部分:
# Create the shortcut file
$shortcut = (New-Object -ComObject WScript.Shell).Createshortcut("$shortcutFolder\target.lnk")
$shortcut.TargetPath = $targetPath
if (
$shortcut.IconLocation = "%SystemRoot%\system32\SHELL32.DLL, 275"
$shortcut.Description = $targetPath
$shortcut.WorkingDirectory = $targetPath
$shortcut.Save()
# Set attributes on the files & folders
$desktopIni | Set-ItemProperty -Name Attributes -Value ([IO.FileAttributes]::System -bxor [IO.FileAttributes]::Hidden)
$shortcutFolder | Set-ItemProperty -Name Attributes -Value ([IO.FileAttributes]::ReadOnly)
如您所见,它当前使用的是 SHELL32.DLL 库中的 Icon #275。在 Windows 7 中,“正确的”图标是 imageres.dll 中的 Icon #143。有没有办法从操作系统获取图标详细信息,例如获取对资源管理器命名空间中特殊文件夹的引用?
最佳答案
我的网上邻居有 CLSID 208d2c60-3aea-1069-a2d7-08002b30309d
知道这一点,您可以在 HKEY_CLASSES_ROOT\CLSID\{208D2C60-3AEA-1069-A2D7-08002B30309D}\DefaultIcon
处读取默认注册表值。
结果将是即 %SystemRoot%\system32\imageres.dll,-25
关于.net - 如何选择正确的 "network place"图标?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13240672/