Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1170
  • Last Modified:

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 http://www.experts-exchange.com/Operating_Systems/Windows_Server_2003/Q_21685085.html?query=add+shortcut+group+policy+icon&clearTAFilter=true

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"
objURLShortcut.Save

'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
'objURLShortcut3.Save
0
jbreg
Asked:
jbreg
  • 3
  • 2
1 Solution
 
David LeeCommented:
Greetings, jbreg.

There is no IconLocation property for a WshURLShortcut object.  See here for details: http://www.devguru.com/Technologies/wsh/quickref/WshUrlShortcut.html  The IconLocation property goes with the WshShortcut object (http://www.devguru.com/Technologies/wsh/quickref/WshShortcut.html).  The former is a shortcut to a URL while the latter is a shortcut to an executable on the local computer.

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

0
 
David LeeCommented:
jbreg,

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.Save
oShellLink.TargetPath = "http://tbisa01/iso/
oShellLink.Save
0
 
jbregAuthor Commented:
BlueDev,

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

Thanks!
0
 
David LeeCommented:
You're welcome.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now