小编Rin*_*ind的帖子

如何使用 Powershell 更改现有 URL 快捷方式的图标?

我想使用 Powershell 更改现有快捷方式的图标。

我尝试了一下,但无法设置更改,所以我上网并空手而归。我见过使用 VB 和 Command Shell 的示例,但没有见过使用 Powershell 的示例。近 99% 演示了如何创建快捷方式,但我只需要知道如何更改图标并且仅更改图标。

这是我到目前为止所做的:

# Make a copy of the icon in the directory
PS> cd Program Files (x86)\Dir\Fol\
PS Program Files (x86)\Dir\Fol> cp 1234567890.ico 12345678901.ico

# Gets the IconFile property and changes it to the new icon
PS Program Files (x86)\Dir\Fol> cd Desktop\Folder\
PS Desktop\Folder>(Get-Content "file name")[6]
IconFile=C:\Program Files (x86)\Dir\Fol\1234567890.ico
PS Desktop\Folder>(Get-Content "file name")[6] -replace ".ico","1.ico"
Run Code Online (Sandbox Code Playgroud)

我尝试过使用,WScript.Shell ComObject但这似乎只会创建新的快捷方式。

我觉得如果有一种方法可以保存、更新和应用IconFile对象中的新路径,我将能够使用它。

由于图标(或者可能是符号 LNK 中的某些内容?)“破坏”并默认为通用图标,我将这样做作为修复操作。似乎只是快捷方式的问题。该快捷方式工作完美,一切都很好,但由于某种原因,图标是默认的。如果我进入并通过 GUI 重新应用相同的图标名称,它不会改变。但是,如果我通过任何措施更改 .ico …

powershell icons shortcut lnk

4
推荐指数
2
解决办法
3万
查看次数

标签 统计

icons ×1

lnk ×1

powershell ×1

shortcut ×1