Guest User

Untitled

a guest
May 10th, 2012
248
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. Set WshShell = WScript.CreateObject("WScript.Shell")
  2.  
  3. 'magic http shiznit
  4. set HTTP = createobject("WinHTTP.WinHTTPRequest.5.1")
  5. http.option(6) = "False" 'disables automagic following of redirects
  6.  
  7. 'regex in the pants
  8. Set objRE = CreateObject("VBScript.RegExp")
  9. objRE.Global = True
  10. objRE.Pattern = "http\:\/\/.*"
  11.  
  12. 'test url
  13. URL="http://TinyURL.com/2wj73j"
  14.  
  15. http.open "GET", URL, False
  16. http.send ""
  17. if err.Number = 0 Then
  18. if http.status = "301" then
  19. set response = objRE.Execute (http.getallresponseheaders)
  20. if response.count <> "1" then
  21. wscript.quit 'error checking :)
  22. end if
  23. wscript.echo response(0)
  24. else
  25. wscript.echo "not a redirect"
  26. end if
  27. Else
  28. Wscript.Echo "error " & Err.Number & ": " & Err.Description
  29. wscript.quit
  30. End If
Add Comment
Please, Sign In to add comment