Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

setting shortcut icons 2

Status
Not open for further replies.

newguy86

Technical User
May 19, 2008
226
US
I use a script to install a shortcut on the end-users desktop and I would like to change the icon to a preloaded image in the system files. I know that I have to use "iconlocation" to do this but I can't seem to figure out how to locate the image I want and set it as the icon.

Code:
Dim oShell
Dim sDesk
Dim oShortCut
Dim strFileName 

Set oShell = CreateObject("WScript.Shell")
sDesk = oShell.SpecialFolders.Item("Desktop")
Set oShortCut = oShell.CreateShortcut(sDesk & "\GDS Db.lnk")

With oShortCut
	.TargetPath = "*********************\Db Opener.vbs"
	.Description = "GDS Db"
	.WorkingDirectory = "************************"
	.IconLocation = "C:\WINDOWS\system32\shell32.dll,0"
        .Save
End With

MsgBox "Installation Complete!"

Any assistance would be greatly appreciated.

Travis
 
The easiest way to find the icon you want is to create your shortcut by hand and select the desired icon. Then use a script to read back the properties of the shortcut. Here's a quick sample I whipped up...

Code:
Dim oShell, oShortcut

Set oShell = CreateObject("WScript.Shell")

Set oShortcut = oShell.CreateShortcut("C:\Log Off.lnk")

With oShortcut
	WScript.Echo .Arguments
	WScript.Echo .Description
	WScript.Echo .IconLocation
	WScript.Echo .TargetPath
	WScript.Echo .WindowStyle
	WScript.Echo .WorkingDirectory
End With

[green]Sample Output


%SystemRoot%\system32\SHELL32.dll,44
C:\Windows\System32\logoff.exe
1
C:\Windows\system32[/green]

Take the returned data and use it for your script.

PSC
[—] CCNP [•] CCSP [•] MCITP: Enterprise Admin [•] MCSE [—]

Governments and corporations need people like you and me. We are samurai. The keyboard cowboys. And all those other people out there who have no idea what's going on are the cattle. Mooo! --Mr. The Plague, from the movie "Hackers
 
Thank you PScottC! Even though I didn't use exactly what you gave me, it did provide me with enough information to get the expected result.

Thanks,

Travis
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top