Computing.Net > Forums > Programming > VBScript File search

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

VBScript File search

Reply to Message Icon

Name: cobyurl3
Date: October 11, 2007 at 07:54:26 Pacific
OS: XP
CPU/Ram: 2.8/1GB
Product: IBM THinkcentre
Comment:

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.



Sponsored Link
Ads by Google

Response Number 1
Name: Razor2.3
Date: October 15, 2007 at 18:43:12 Pacific
Reply:

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
Next

Function 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


0
Reply to Message Icon

Related Posts

See More







Post Locked

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


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: VBScript File search

Visual Basics File Search www.computing.net/answers/programming/visual-basics-file-search/7891.html

vb 6 preforming file search www.computing.net/answers/programming/vb-6-preforming-file-search/5476.html

Batch File Search Functionality www.computing.net/answers/programming/batch-file-search-functionality/12935.html