-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