How to change the icon of .bat file programmatically?

前端 未结 10 647
予麋鹿
予麋鹿 2021-02-05 00:45

I\'d like to know what\'s the way to actually set the icon of a .bat file to an arbitrary icon. How would I go about doing that programmatically, independently of t

10条回答
  •  爱一瞬间的悲伤
    2021-02-05 01:02

    You can just create a shortcut and then right click on it -> properties -> change icon, and just browse for your desired icon. Hope this help.

    To set an icon of a shortcut programmatically, see this article using SetIconLocation:

    How Can I Change the Icon for an Existing Shortcut?:

    https://devblogs.microsoft.com/scripting/how-can-i-change-the-icon-for-an-existing-shortcut/

    Const DESKTOP = &H10&
    Set objShell = CreateObject("Shell.Application")
    Set objFolder = objShell.NameSpace(DESKTOP)
    Set objFolderItem = objFolder.ParseName("Test Shortcut.lnk")
    Set objShortcut = objFolderItem.GetLink
    objShortcut.SetIconLocation "C:\Windows\System32\SHELL32.dll", 13
    objShortcut.Save
    

提交回复
热议问题