-2
我做了一个脚本,检查用户桌面上是否存在链接,如果没有找到,它会创建它。 但是然后我想要那个链接改变图标,我不知道该怎么做。我尝试使用我创建的objDesktop
,但它似乎是不同类型的对象,所以我不能使用ParseName
或GetLink
来对付它。如何在创建链接后更改链接的图标?
代码示例如下:
Set wShell = CreateObject("Wscript.Shell")
Set objFso = WScript.CreateObject("Scripting.FileSystemObject")
Set objDesktop = objFso.GetFolder(wShell.SpecialFolders("Desktop"))
linkName = "\Notepad.lnk"
fullLinkPath = objDesktop & linkName
If (objFso.FileExists(fullLinkPath)) = False Then
Set shortcut = wShell.CreateShortcut(fullLinkPath)
shortcut.targetpath = "c:\Windows\notepad.exe"
shortcut.Save
End If
'from here, I want that freshly created link to have its icon replaced with
'another ico file that will be provided.
我想保持代码的简单和最小的越好,所以如果我的方法到现在为止是不会导致我到一个一致的结果,请给我一个更好的代码示例。
与创建链接的方式非常相似,只需删除if并更改图标即可。 'shortcut.IconLocation =“%SystemRoot%\ system32 \ SHELL32.dll,1”' – LotPings