Hi Everyone,
Im new this this forum but im hoping someone out there can help me.
Im looking to create a VBS which can search a users desktop and the All users desktop folders for any shortcuts LNK or URL (with for example -
http://www.google.co.uk as the target) and delete these shortcuts.
So far i have come up with
"
Set oNetwork = CreateObject("WScript.Network")
' String in the target property to search for
sTargetStrOld = "http://www.google.co.uk"
Set oShell = CreateObject("WScript.Shell")
set oFso = CreateObject("Scripting.FilesystemObject")
' Check all shortcuts on the users desktop
sPath = oShell.SpecialFolders("Desktop")
ChkLnk(sPath)
' Check all shortcuts on the "All Users" desktop
sPath = oShell.SpecialFolders("AllUsersDesktop")
ChkLnk(sPath)
Sub ChkLnk (sFolder)
Set oFolder = oFso.GetFolder(sFolder)
Set oFiles = oFolder.Files
For Each oFile In oFiles
If LCase(oFso.GetExtensionName(oFile)) = "lnk" Then
Set oLnk = oShell.createShortcut(oFile)
If LCase(oLnk.TargetPath) = LCase(sTargetStrOld) Then
oLnk.delete
End If
End If
Next
End Sub
"
But im kind of stuck here, it runs without any errors but doesnt delete any shortcuts.
Can anyone tell me where im going wrong, or have any examples of how to do this properly?
Thanks
Allan