Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I need a VBScript to a shortcut on any user's desktop by it's URL or Targetpath only. Different users call the same shortcut different things. we want to find the shortcut and delete it. Anybody have any ideas, thanks.

The problem, as I see it, is VBS, which has no way of interacting with shortcuts, outside of creating them. Therefore, we must test the file for the string we're looking for, which may or may not return anything meaningful.
(Note: If this is something on a network drive, leave off the share name and/or the mapped drive letter.)
const sLookFor = "Important Links"
sDesktop = WScript.CreateObject("WScript.Shell").ExpandEnvironmentStrings("%UserProfile%\Desktop")
Set oFSO = CreateObject("Scripting.FileSystemObject")For Each file In oFSO.GetFolder(sDesktop).Files
If BCheckFile(file) Then file.Delete
NextFunction BCheckFile(oFile)
BCheckFile = False
Dim sShortcut
sShortcut = oFile.OpenAsTextStream(1, 0).ReadAll _
& oFile.OpenAsTextStream(1, -1).ReadAll
If InStr(1, sShortCut, sLookFor, 1) Then _
BCheckFile = True
End Function

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |