How can I change the icon of a url that I created

Good afternoon experts,

The following code snippent should create a desktop shortcut with the icon path that I associated with it:

Set objShell = CreateObject("WScript.Shell")
strDesktopFld = objShell.SpecialFolders("Desktop")
Set objURLShortcut = objShell.CreateShortcut(strDesktopFld & "\NYOI 2012 National Outcomes Unique Web survey.url")
objURLShortcut.TargetPath = ""
objURLShortcut.IconLocation =  "\\wks-wnxp-01901\YOUTHDB\icos\Nyoi.ico,0"

When I run the vbs file I get the following error:

 Microsoft VBScript runtime error: Object doesn't support this property or method: 'objURLShortcut.IconLocation'

I am probably mission something very simple , because I have looked at the syntax of the .iconlocation property and it looks correct to me.  Any thoughts.
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.

I think you have to correct the path

like this example
fundacionrtsAdministrador de SistemasCommented:
CreateShortcut of URL type only support:

* FullName Property
* TargetPath Property

Unfortunately, you cannot change the icon for a URL shortcut as fundacionrts stated above.
HOWEVER, what you could do is make a shortcut to Internet Explorer and specify the url to open.

to do this, just change your TargetPath to:
"C:\Program Files\Internet Explorer\iexplore.exe"

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
Active Protection takes the fight to cryptojacking

While there were several headline-grabbing ransomware attacks during in 2017, another big threat started appearing at the same time that didn’t get the same coverage – illicit cryptomining.

rlandquist is correct.  If you create an .LNK file, instead of a .URL file, you can change the .Icon property.


Stay tuned,

I am testing things out now everyone. I might have to share the point on this one.
>>  I might have to share the point on this one

Not with me....I didn't help, I'm just agreeing ;-)


Have you ever inspected a *.URL file in a text editor?

It's just plain text in a format like an *.INI file with standard CR/LF's, and can be created easily by redirecting a series of text strings to the file so that each desired parameter is on a separate line.  You might have to escape some of the characters in the strings so that they are written literally.

IconFile=   (path to ico, exe, dll, or other "library" file containing icons)
IconIndex=  (index number of icon starting from Zero)


Some of the lines are only really used for *.URL files created as Internet Explorer "Favorites".
Interesting BillDL.  This seems to be what I am looking for. I will see how difficult the process is and get back to this forum. I can escape characters easily enough, I just want to be able to use this solution to embed the path to the icon into it.
rlandquist and Billdl  each gave me a solution to my problem, however, rlandquist's solution  was the most efficient and quickest way to set an icon.
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 7

From novice to tech pro — start learning today.