情況是這樣的:
我之前做了一個網頁捷徑讓其他使用者在桌面點,
而當初是請其他人手動複製到那N台電腦桌面上(我沒有權限可以遠端連到這些電腦),
今天主管希望換掉那些桌面捷徑圖示,改成特別一點,而不是Chrome的三色球,
我知道可以在捷徑按右鍵【內容】【變更圖示】去改,
但除了教他們按右鍵去改外,有沒有辦法用像改網頁icon
<link rel="icon" href="http://xxx/yyy.ico" type="image/x-icon" />
這種方式固定去做呢?
就是只要複製捷徑到桌面就把上面的動作都完成呢?
ChatGPT 回答
可以用 Powershell 或 VBScript
Powershell
# Define the path to the shortcut
$shortcutPath = "C:\path\to\your\shortcut.lnk"
# Define the path to the new icon file
$newIconPath = "C:\path\to\your\new\icon.ico"
# Create a WScript Shell object
$shell = New-Object -ComObject WScript.Shell
# Get the shortcut object
$shortcut = $shell.CreateShortcut($shortcutPath)
# Set the icon path for the shortcut
$shortcut.IconLocation = $newIconPath
# Save changes to the shortcut
$shortcut.Save()
Replace C:\path\to\your\shortcut.lnk with the path to your shortcut and C:\path\to\your\new\icon.ico with the path to the new icon file you want to use.
Save this PowerShell script as a .ps1 file and run it using PowerShell.
VBScript
' Define the path to the shortcut
shortcutPath = "C:\path\to\your\shortcut.lnk"
' Define the path to the new icon file
newIconPath = "C:\path\to\your\new\icon.ico"
' Create a Shell object
Set shell = CreateObject("WScript.Shell")
' Get the shortcut object
Set shortcut = shell.CreateShortcut(shortcutPath)
' Set the icon path for the shortcut
shortcut.IconLocation = newIconPath
' Save changes to the shortcut
shortcut.Save
Replace C:\path\to\your\shortcut.lnk with the path to your shortcut and C:\path\to\your\new\icon.ico with the path to the new icon file you want to use.
Save this VBScript as a .vbs file and run it by double-clicking the file.
Remember that when changing the icon of a shortcut, the icon file should be accessible and the path to the icon should be valid.
關鍵字是: favicon ico size
或 HTML <link> sizes Attribute
。
大致像下面這樣在index.html
的<head></head>
裡,
放入各式各樣的圖示大小
<link rel="icon" type="image/png" href="/path/to/icons/favicon-16x16.png" sizes="16x16">
<link rel="icon" type="image/png" href="/path/to/icons/favicon-32x32.png" sizes="32x32">
這裡有大小的建議,通常是放手機板、平板、筆電、桌機大小的icon即可。
16x16: The size of browser favicons.
32x32: The size of taskbar shortcut icons.
96x96: The size of desktop shortcut icons.
180x180: The size of Apple touch icons.
300x300: The size required by Squarespace.
當然還要看各家瀏覽器支援的程度,是否有支援favicon ico size
。
以及寫法可能會有些許不同(印象中 Safari 寫法好像不太一樣)