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

Posted on 2006-04-17
Last Modified: 2012-06-21
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
Question by:jbreg
    LVL 76

    Expert Comment

    by:David Lee
    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.


    Author Comment

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

    LVL 76

    Accepted Solution


    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/"

    Author Comment


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

    LVL 76

    Expert Comment

    by:David Lee
    You're welcome.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Maximize Your Threat Intelligence Reporting

    Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

    So you have two Windows Servers and you have a directory/folder/files on one that you'd like to mirror to the other?  You don't really want to deal with DFS or a 3rd party solution like Doubletake. You can use Robocopy from the Windows Server 200…
    A quick step-by-step overview of installing and configuring Carbonite Server Backup.
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now