mbt masai
 
Welcome !
         

                                
After experiencing a lot of down time, We decided to move this site to CrystalTech.com. CrystalTech.com is powered by only the finest Windows servers providing the best performance, reliability, and value anywhere.

 Help needed, VBS to check a shortcut and delete it

Author Message
allan123

  • Total Posts : 1
  • Scores: 0
  • Reward points : 0
  • Joined: 3/10/2010
  • Status: offline
Help needed, VBS to check a shortcut and delete it Wednesday, March 10, 2010 3:30 AM (permalink)
0
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
#1

    Online Bookmarks Sharing: Share/Bookmark

    Jump to:

    Current active users

    There are 0 members and 1 guests.

    Icon Legend and Permission

    • New Messages
    • No New Messages
    • Hot Topic w/ New Messages
    • Hot Topic w/o New Messages
    • Locked w/ New Messages
    • Locked w/o New Messages
    • Read Message
    • Post New Thread
    • Reply to message
    • Post New Poll
    • Submit Vote
    • Post reward post
    • Delete my own posts
    • Delete my own threads
    • Rate post

    2000-2012 ASPPlayground.NET Forum Version 3.8
    mbt shoes www.wileywilson.com