2
Dim FileObj, fso, strOutFileName, objFileOut, HTTP, strDeadLinkFolder
3
Dim WshShell, strFavorite, strDocuments, subfolder, subfiles, subFlds2, fld2
5
set WshShell = WScript.CreateObject("WScript.Shell")
6
strFavorite = WshShell.SpecialFolders("Favorites")
7
strDocuments = WshShell.SpecialFolders("MyDocuments")
9
strOutFileName = "FavoritesValidation.log"
11
strDeadLinkFolder = "DeadLinks"
13
Set fso = CreateObject("Scripting.FileSystemObject")
14
Set objFileOut = fso.createtextfile(strDocuments & "\" & strOutFileName)
15
Set HTTP = CreateObject("Microsoft.XMLHTTP")
17
FolderContent strFavorite
19
Sub FolderContent (strCurrentFolder)
20
Dim folder, files, file, subFlds, fld, strPath, strLine, strLineParts, bFoundURL
22
Set folder = fso.GetFolder(strCurrentFolder)
23
strPath = mid(folder.path, len(strFavorite)+2)
24
if strPath <> "" then strPath = strPath & "\"
25
Set files = folder.Files
26
Set subFlds = folder.SubFolders
28
For Each file in files
29
if file.name <> "desktop.ini" then
31
' wscript.echo "Opening " & file.path '& "\" & file.name
32
Set FileObj = fso.opentextfile(file.path)
33
' writeout strpath & file.name
34
While not fileobj.atendofstream
35
strLine = Trim(FileObj.readline)
36
strLineParts = split (strLine, "=")
37
If strLineParts(0) = "URL" Then
38
' wscript.echo "testing URL " & strLineParts(1)
40
HTTP.Open "GET", strLineParts(1), False
42
if Err.Number > 0 then
43
writeout strpath & file.name & "; " & strLineParts(1) & "; " & Err.Number & Err.Description
45
writeout strpath & file.name & "; " & strLineParts(1) & "; " & HTTP.statusText
48
If HTTP.statusText <> "OK" Then
49
' writeout strLineParts(1) & " is not OK, moving to c:\" & strDeadLinkFolder & "\" & file.name
50
' file.copy ("c:\" & strDeadLinkFolder & "\" & file.name)
51
' file.move ("c:\" & strDeadLinkFolder & "\" & file.name)
53
' fso.movefile file.path, "c:\" & strDeadLinkFolder & "\" & file.name
58
if bFoundURL = false Then
59
writeout "Couldn't find URL in " & file.path & "\" & file.name
63
For Each fld in subFlds
71
objFileOut.writeline msg