Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Set WshShell = WScript.CreateObject("WScript.Shell")
- 'magic http shiznit
- set HTTP = createobject("WinHTTP.WinHTTPRequest.5.1")
- http.option(6) = "False" 'disables automagic following of redirects
- 'regex in the pants
- Set objRE = CreateObject("VBScript.RegExp")
- objRE.Global = True
- objRE.Pattern = "http\:\/\/.*"
- 'test url
- URL="http://TinyURL.com/2wj73j"
- http.open "GET", URL, False
- http.send ""
- if err.Number = 0 Then
- if http.status = "301" then
- set response = objRE.Execute (http.getallresponseheaders)
- if response.count <> "1" then
- wscript.quit 'error checking :)
- end if
- wscript.echo response(0)
- else
- wscript.echo "not a redirect"
- end if
- Else
- Wscript.Echo "error " & Err.Number & ": " & Err.Description
- wscript.quit
- End If
Add Comment
Please, Sign In to add comment