Avatar of chipw93
chipw93

asked on 

Change Shortcut Icon to another(any) standard Windows icon while creating shortcut via script

I have the following vbs script running as a logon script.  But everytime it runs, When the shortcut is created, it is created with the symbol of no icon.  How can I direct the icon location to an actual windows system icon file.   When I open up a file via properties, and browse for a new icon, it directs me to look in shell32.dll, but I can't find a way to get to all of those icons shown in that window.   I don't want to use the default "bowser" icon that is chosen for web based shortcuts

Thanks



set objShell = Wscript.Createobject("Wscript.Shell")
strDesktopFld = objShell.SpecialFolders("Desktop")
Set objURLShortcut = objShell.createShortcut(strDesktopFld & "\Install-CoM-Applications.lnk")
'Name for Shortcut to add
objURLShortcut.Targetpath = "http://localhost:9595/webportal/webportal.exe"
'Path to icon
objURLShortcut.IconLocation = "C:\WINDOWS\system32\oobe\images\thanks8.png"
'Path for Shortcut
objURLShortcut.Save
I have the following vbs script running as a logon script.  But everytime it runs, When the shortcut is created, it is created with the symbol of no icon.  How can I direct the icon location to an actual windows system icon file.   When I open up a file via properties, and browse for a new icon, it directs me to look in shell32.dll, but I can't find a way to get to all of those icons shown in that window.
 
Thanks
 
 
 
set objShell = Wscript.Createobject("Wscript.Shell")
strDesktopFld = objShell.SpecialFolders("Desktop")
Set objURLShortcut = objShell.createShortcut(strDesktopFld & "\Install-CoM-Applications.lnk")
'Name for Shortcut to add
objURLShortcut.Targetpath = "http://localhost:9595/webportal/webportal.exe"
'Path to icon
objURLShortcut.IconLocation = "C:\WINDOWS\system32\oobe\images\thanks8.png"
'Path for Shortcut
objURLShortcut.Save

Open in new window

VB Script

Avatar of undefined
Last Comment
RobSampson
Avatar of RobSampson
RobSampson
Flag of Australia image

Hi, change this:
objURLShortcut.IconLocation = "C:\WINDOWS\system32\oobe\images\thanks8.png"

to this:
objURLShortcut.IconLocation = "SHELL32.dll, 18"

which will get the 19th icon from SHELL32.dll

Regards,

Rob.
Avatar of Shift-3
Shift-3
Flag of United States of America image

If you just want the default browser icon then it's probably simplest to generate the shortcut with a .url extension instead of .lnk.



set objShell = Wscript.Createobject("Wscript.Shell")
strDesktopFld = objShell.SpecialFolders("Desktop")
Set objURLShortcut = objShell.createShortcut(strDesktopFld & "\Install-CoM-Applications.url")
'Name for Shortcut to add
objURLShortcut.Targetpath = "http://localhost:9595/webportal/webportal.exe"
'Path for Shortcut
objURLShortcut.Save

Open in new window

Avatar of chipw93
chipw93

ASKER

I don't want the default icon, that is what I had and was trying to change.

To Rob, is there no way to point to the actual icon.  With this method, I would need to scroll and count through each icon and try to determine, which one is number 19, 20, etc... as opposed to, if I could line them up in a window, and say, look at the thumbnails and filenames,  I could quickly identify.....X as the one that I want.

But I will at least implement your idea as it gets me closer than I was 20 minutes ago

Avatar of chipw93
chipw93

ASKER

Ok, for an update, and Rob, I will give you the points, if you can give me this addendum... and really, I guess you should get the points since that does solve my issue, but building on my last comment.  Do you know of a resource or site that tells me what icon goes with what number, so that I don't have to blindly pick a number, login, and see which icon I get?

Avatar of RobSampson
RobSampson
Flag of Australia image

Hi, I can't find a source that gives you each icon with it's number, but I did find a small start:
http://www.microsoft.com/technet/scriptcenter/resources/qanda/aug05/hey0812.mspx

there's an image at the bottom that tells you how they're numbered.

Regards,

Rob.
ASKER CERTIFIED SOLUTION
Avatar of RobSampson
RobSampson
Flag of Australia image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
VB Script
VB Script

VBScript (Visual Basic Scripting Edition) is an interpreted scripting language developed by Microsoft that is modeled on Visual Basic, but with some important differences. VBScript is commonly used for automating administrative and other tasks in Windows operating systems (by means of the Windows Script Host) and for server-side scripting in ASP web applications. It is also used for client-side scripting in Internet Explorer, specifically in intranet web applications.

39K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo