Property:  WshShortcut.IconLocation

object.IconLocation

The IconLocation property sets or retrieves a String that is the location of the icon used to represent the shortcut. The string is of the form "path,index", where path is the full path to the file containing the icon, and index is the zero-based index of the icon within the specified icon file.

Specifying an invalid value for this property will not cause an error. However, the icon that will be displayed for the shortcut may be changed. Setting this property to the empty string restores the shortcut's default icon.

The following JScript code sets the icon for a shortcut called "Shortcut to Test.vbs.lnk" to the 4th icon (since the icons are zero-indexed) in the shell32.dll file.

Code:
objShell = WScript.CreateObject("WScript.Shell")
objShtCut = objShell.CreateShortcut
    ("C:\\Documents And Settings\\DevGuru\\Desktop\\Shortcut To Test.vbs.lnk") objShtCut.IconLocation = "C:\\winnt\\system32\\shell32.dll,3"
objShtCut.Save()
WScript.Echo(objShtCut.IconLocation)


Output:
C:\WINNT\system32\shell32.dll,3

Copyright 1999-2001 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information