TriCountyIT
asked on
VB Script to remove shortcut from desktop
Hello, I have found a new way to deploy desktop shortcuts on our client PC's. The issue is that I currently have VB scripts running to do the same thing via log on script. I have attached the code I use to create those icons. What could I add or change in this script to look for the icon and remove it. Basically I want to reverse what I have been doing.
'FORCE EXPLICIT VARIABLE DECLARATION
option explicit
'STEP OVER ERRORS FOR CUSTOM ERROR REPORTING
on error resume next
'DECLARE VARIABLES
dim shell, desktopPath, link, sys32Path
'INSTANTIATE THE WINDOWS SCRIPT HOST SHELL OBJECT
Set shell = WScript.CreateObject("WScr ipt.shell" )
'SET THE PATH TO THE WINDOWS DESKTOP FOLDER & MY DOCUMENTS FOLDER
desktopPath = shell.SpecialFolders("Desk top")
sys32Path = "http://epic1ctx/Citrix/TriCounty/auth/login.aspx"
'CREATE A SHORTCUT ON THE USER'S DESKTOP
Set link = shell.CreateShortcut(deskt opPath & "\TriCounty Citrix.lnk")
'SET THE PROPERTIES FOR THE SHORTCUT
link.Description = "My Shortcut"
link.TargetPath = sys32Path
link.WindowStyle = 0
link.WorkingDirectory = desktopPath
link.IconLocation = "\\tch16\IT\ShortcutIcons\ epic.ico"
link.Save
'CLEANUP OBJECTS
set shell = nothing
'FORCE EXPLICIT VARIABLE DECLARATION
option explicit
'STEP OVER ERRORS FOR CUSTOM ERROR REPORTING
on error resume next
'DECLARE VARIABLES
dim shell, desktopPath, link, sys32Path
'INSTANTIATE THE WINDOWS SCRIPT HOST SHELL OBJECT
Set shell = WScript.CreateObject("WScr
'SET THE PATH TO THE WINDOWS DESKTOP FOLDER & MY DOCUMENTS FOLDER
desktopPath = shell.SpecialFolders("Desk
sys32Path = "http://epic1ctx/Citrix/TriCounty/auth/login.aspx"
'CREATE A SHORTCUT ON THE USER'S DESKTOP
Set link = shell.CreateShortcut(deskt
'SET THE PROPERTIES FOR THE SHORTCUT
link.Description = "My Shortcut"
link.TargetPath = sys32Path
link.WindowStyle = 0
link.WorkingDirectory = desktopPath
link.IconLocation = "\\tch16\IT\ShortcutIcons\
link.Save
'CLEANUP OBJECTS
set shell = nothing
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
This worked perfect. THanks
Can you please explain why my solution was not picked as it essentially the same thing and was posted first. I am curious.
-Bear
-Bear
ASKER
Of course. I tried your script and it didnt work. For whatever reason it would not remove the icon. So, instead of messaging you to troubleshoot I tried the other script and it worked so I just accepted the other one. I am sure someone with a little more VB background could have seen what the issue was and it would have worked just fine, but I am for sure not that guy. The script I posted I got from an expert on this site a couple years ago. I appreciate the speedy response though. Thanks alot.
Your welcome :)
Open in new window