Add a Shortcut via Group Policy - Can't Set Icon Properly

I am trying to add a shortcut to everyone's desktop via a GP as in

Everything works except in the setting of the icon location. I set it, I know the user has access to it, and yet the icon stays the standard icon, the property is not set. I see the problem is "Object doesn't support this property or method: 'objURLShortcut.IconLocation'

I have copied the script I am using, I tried to modify it with the one line

objURLShortcut.IconLocation = "\\tbnas01\Graphics\eCourier.ico"

What am I doing wrong?

'Make sure no pops up error messages occure. Set to ignore all errors.
'On Error Resume Next

'First, delete old shortcut with the same name.
'Set objFSO1 = CreateObject("Scripting.FileSystemObject")
'Set objShell1 = WScript.CreateObject("WScript.Shell")
'strDesktopFld1 = objShell1.SpecialFolders("Desktop")
'objFSO1.DeleteFile(strDesktopFld1 & "\HelpDesk.url") ' This is the shortcut you are looking to delete.

'Delete Quick Launch Icon
'Set objFSO2 = CreateObject("Scripting.FileSystemObject")
'Set objShell2 = WScript.CreateObject("WScript.Shell")
'Set colEnvironmentVariables = objShell2.Environment("Volatile")

' Also adds to the Quick Launch
'strQLFolder2 = colEnvironmentVariables.Item("APPDATA") & _
'"\Microsoft\Internet Explorer\Quick Launch"
'objFSO2.DeleteFile(strQLFolder2 & "\HelpDesk.url") ' This is the shortcut you are looking to delete

'Create new shortcut with correct path.
Set objShell = WScript.CreateObject("WScript.Shell")
strDesktopFld = objShell.SpecialFolders("Desktop")
Set objURLShortcut = objShell.CreateShortcut(strDesktopFld & "\eCourier_ISO.url") ' Name for Shortcut to add
objURLShortcut.TargetPath = "http://tbisa01/iso/" ' Path for shortcut
objURLShortcut.IconLocation = "\\tbnas01\Graphics\eCourier.ico"

'Create Quick Launch Icon
'Set objShell3 = WScript.CreateObject("WScript.Shell")
'Set colEnvironmentVariables = objShell3.Environment("Volatile")

'strQLFolder = colEnvironmentVariables.Item("APPDATA") & _
'"\Microsoft\Internet Explorer\Quick Launch"

'Set objURLShortcut3 = objShell2.CreateShortcut(strQLFolder & "\eCourier_ISO.url") ' Name for Shortcut to add
'objURLShortcut3.TargetPath = "http://miiwebserv01/tiweb60/selfservice" ' Path for shortcut
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

David LeeCommented:
Greetings, jbreg.

There is no IconLocation property for a WshURLShortcut object.  See here for details:  The IconLocation property goes with the WshShortcut object (  The former is a shortcut to a URL while the latter is a shortcut to an executable on the local computer.

jbregAuthor Commented:
Ok, can I accomplish the same result with a different object which supports that property?

David LeeCommented:

It seems strange that there's no IconLocation property with a URL shortcut, yet when you create one manually there's an option to change the icon.  The way aroudn the dilemma seems to be to create a shortcut to an executable, set the icon property, save the shortcut, then change the target to the URL.  Something like this example from the Windows Scripting Technologies help file that I've modified:

Set WshShell = WScript.CreateObject("WScript.Shell")
strDesktop = WshShell.SpecialFolders("Desktop")
Set oShellLink = WshShell.CreateShortcut(strDesktop & "\Shortcut Script.lnk")
oShellLink.TargetPath = WScript.ScriptFullName
oShellLink.WindowStyle = 1
oShellLink.Hotkey = "CTRL+SHIFT+F"
oShellLink.IconLocation = "\\tbnas01\Graphics\eCourier.ico"
oShellLink.Description = "Shortcut Script"
oShellLink.WorkingDirectory = strDesktop
oShellLink.TargetPath = "http://tbisa01/iso/

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jbregAuthor Commented:

I agree, that's really weird (that you can set the property manually but not via a script). Anyway, your new solution works great!

David LeeCommented:
You're welcome.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows Server 2003

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.