VB Script Help

I have a VB script that runs at logon. This script creates some desktop shortcuts on the users computers. I've listed the code in this post. The script I've listed works great but now I have the need to update the link which I know all I need to do is edit the URL in the script but could someone tell me the code I need to delete the old URL/shortcuts from the desktop? Also, right now these shortcuts have the default blue IE icon as the picture. I have a tool to make an icon but how would I add that icon picture instead of the blue IE picture?
Set objShell = WScript.CreateObject("WScript.Shell")
 
strDesktopFolder = objShell.SpecialFolders("Desktop")
 
'a link to an app
 
'set objShortcut= objShell.CreateShortcut(strDesktopFolder & "\\Internet Explorer.lnk")
'objShortcut.TargetPath = "c:\Program Files\Internet Explorer\iexplore.exe"
'objShortcut.Hotkey = "CTRL+SHIFT+I"
'objShortcut.Description = "Launch Internet Explorer"
'objShortcut.WorkingDirectory = strDesktopFolder
'objShortcut.Save
 
'a web URL link
 
set objURL= objShell.CreateShortcut(strDesktopFolder & "\InOut Board.url")
objURL.TargetPath = "http://mysite.net"
objURL.Save

Open in new window

LVL 15
wantabe2Asked:
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.

sirbountyCommented:
You 'update' it simply by following the same method...
To point to the icon, you would use the IconLocation property.



Set objShell = WScript.CreateObject("WScript.Shell")
 
strDesktopFolder = objShell.SpecialFolders("Desktop")
 
'a link to an app
 
'set objShortcut= objShell.CreateShortcut(strDesktopFolder & "\\Internet Explorer.lnk")
'objShortcut.TargetPath = "c:\Program Files\Internet Explorer\iexplore.exe"
'objShortcut.Hotkey = "CTRL+SHIFT+I"
'objShortcut.Description = "Launch Internet Explorer"
'objShortcut.WorkingDirectory = strDesktopFolder
'objShortcut.Save
 
'a web URL link
 
set objURL= objShell.CreateShortcut(strDesktopFolder & "\InOut Board.url")
objURL.TargetPath = "http://myNEWsite.net"
objURL.IconLocation ="\\Server\Share\Icons\InOut.ico"
objURL.Save

Open in new window

0
sirbountyCommented:
Of course, if you're using a certain icon from a DLL, you'd use something like:

objURL.IconLocation = "\\Server\Share\Icons\MyIcon.dll,5" 'where 5 is the cardinal number of the icon to reference
0
wantabe2Author Commented:
Here's my new code:


I've also attached the error message in a .pdf file.


Any idea why I'm getting the VB error message? The folder on the server where the icon is is shared with EVERYONE full share & NTFS permissions.
Set objShell = WScript.CreateObject("WScript.Shell")
 
strDesktopFolder = objShell.SpecialFolders("Desktop")
 
'a link to an app
 
'set objShortcut= objShell.CreateShortcut(strDesktopFolder & "\\Internet Explorer.lnk")
'objShortcut.TargetPath = "c:\Program Files\Internet Explorer\iexplore.exe"
'objShortcut.Hotkey = "CTRL+SHIFT+I"
'objShortcut.Description = "Launch Internet Explorer"
'objShortcut.WorkingDirectory = strDesktopFolder
'objShortcut.Save
 
'a web URL link
 
set objURL= objShell.CreateShortcut(strDesktopFolder & "\InOut Board.url")
objURL.TargetPath = "http://156.125.44.140/iomain.php"
objURL.Save
 
set objURL= objShell.CreateShortcut(strDesktopFolder & "\PACTS.url")
objURL.TargetPath = "https://site1.com"
objURL.Save
 
set objURL= objShell.CreateShortcut(strDesktopFolder & "\PACTSV55T.url")
objURL.TargetPath = "https://site2.com"
objURL.Save
 
 
set objURL= objShell.CreateShortcut(strDesktopFolder & "\NewPACTSV55.url")
objURL.TargetPath = "https://site3.com"
objURL.IconLocation = "\\156.125.45.82\icons\pacts.ico"
objURL.Save

Open in new window

0
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

wantabe2Author Commented:
The rror code did not upload for some reason but the VB error I am getting is on line 31. It says "Object doesn't support this property or method objURL.IconLocation
0
sirbountyCommented:
Ah, cause you have it as a URL, not a shortcut link...
Try this:


Set objShell = WScript.CreateObject("WScript.Shell")
 
strDesktopFolder = objShell.SpecialFolders("Desktop")
 
'a link to an app
 
'set objShortcut= objShell.CreateShortcut(strDesktopFolder & "\\Internet Explorer.lnk")
'objShortcut.TargetPath = "c:\Program Files\Internet Explorer\iexplore.exe"
'objShortcut.Hotkey = "CTRL+SHIFT+I"
'objShortcut.Description = "Launch Internet Explorer"
'objShortcut.WorkingDirectory = strDesktopFolder
'objShortcut.Save
 
'a web URL link
 
set objURL= objShell.CreateShortcut(strDesktopFolder & "\InOut Board.url")
objURL.TargetPath = "http://156.125.44.140/iomain.php"
objURL.Save
 
set objURL= objShell.CreateShortcut(strDesktopFolder & "\PACTS.url")
objURL.TargetPath = "https://site1.com"
objURL.Save
 
set objURL= objShell.CreateShortcut(strDesktopFolder & "\PACTSV55T.url")
objURL.TargetPath = "https://site2.com"
objURL.Save
 
 
set objURL= objShell.CreateShortcut(strDesktopFolder & "\NewPACTSV55.lnk")
objURL.TargetPath = "https://site3.com"
objURL.IconLocation = "\\156.125.45.82\icons\pacts.ico"
objURL.Save

Open in new window

0
wantabe2Author Commented:
That works GREAT! Thank you. If I wanted to delete the ICON pushed out on lines 20, 21, and 22... if I rem out those lines the icon stays on the desktop after running this script. If I wanted to get rid of the icon pushed out on line 20, 21, and 22..what is the code to do that?
0
sirbountyCommented:
No need to set an object reference if you're deleting them.
Just use an fso reference:

Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.DeleteFile strDesktopFolder & "\PACTS.url"

0

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
wantabe2Author Commented:
When I added that code to the end of my script I get the error:
FILE NOT FOUND referencing line - objFSO.DeleteFile strDesktopFolder & "\PACTSV55T.url"

As you can see I am clueless with VB :)
0
wantabe2Author Commented:
UPDATE

Ok, with the
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.DeleteFile strDesktopFolder & "\PACTSV55T.url"
code in the script, it actually disables the icon by taking away the URL path but the icon is still there. Is there a way to totally get rid of the icon?
0
wantabe2Author Commented:
The shortcut I'm trying to delete is an Internet shortcut if that helps...
0
sirbountyCommented:
Right-click the icon - what is the name of the file?
0
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
Visual Basic Classic

From novice to tech pro — start learning today.