Advertisement
lmohanarun

VBScript demo of how to check a list of links in a text file

Oct 15th, 2015
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Set objFSO = CreateObject("Scripting.FileSystemObject")
  2. Set objReadFile = objFSO.OpenTextFile("C:\New Folder\ReadList.txt")
  3. Set objFolder = objFSO.GetFolder("C:\New Folder")
  4. Set TextStream200 = objFolder.CreateTextFile("WriteList200.txt")
  5. Set TextStreamN = objFolder.CreateTextFile("WriteListNot200.txt")
  6. On Error Resume Next
  7.  
  8. Dim arrFileLines()
  9. i = 0
  10. Do Until objReadFile.AtEndOfStream
  11.     Redim Preserve arrFileLines(i)
  12.     arrFileLines(i) = objReadFile.ReadLine
  13.     i = i + 1
  14. Loop
  15. objReadFile.Close
  16.  
  17. WScript.Echo "Number of links to be checked:"
  18. arrCount = UBound(arrFileLines)+1
  19. WScript.Echo arrCount
  20.  
  21. Set objhttp = CreateObject("WinHttp.WinHttpRequest.5.1")
  22. For Each strLine in arrFileLines
  23.    WScript.Echo strLine
  24.    objhttp.Open "GET", strLine, False
  25.    objhttp.send ""
  26.    
  27.    WScript.Echo objhttp.status
  28.    WScript.Echo objhttp.statusText
  29.  
  30.    If objhttp.status = 200 Then
  31.    TextStream200.WriteLine strLine
  32.    Else
  33.    TextStreamN.WriteLine strLine
  34.    End If
  35.    WScript.Sleep 1250 '1.3 seconds 1300 milli-
  36. Next 'line 22
  37.  
  38. TextStream200.Close
  39. TextStreamN.Close
  40. WScript.Echo "Number of links checked:"
  41. WScript.Echo arrCount
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement