1. Create a VBScript, i.e.:
Set objArgs = WScript.Arguments
Set xmlhttp = Wscript.CreateObject("Microsoft.xmlhttp")
xmlhttp.open "GET", objArgs(0), False
xmlhttp.send
WScript.Echo objArgs(0)
WScript.Echo xmlhttp.status
Then from the command line just run:
cscript //nologo scriptname.vbs http://www.siteyouwanttocheck.com/page.htm
Set objArgs = WScript.Arguments
Set xmlhttp = Wscript.CreateObject("Microsoft.xmlhttp")
xmlhttp.open "GET", objArgs(0), False
xmlhttp.send
WScript.Echo objArgs(0)
WScript.Echo xmlhttp.status
Then from the command line just run:
cscript //nologo scriptname.vbs http://www.siteyouwanttocheck.com/page.htm
2. For a little bit more complex version with proper error message returned:
Set objArgs = WScript.Arguments params =
"SaPrincipalName=test&SaPrincipalPassword=test"
Set xmlhttp =
Wscript.CreateObject("MSXML2.XMLHTTP") '("Microsoft.xmlhttp")
xmlhttp.open "POST",
objArgs(0)+"/login.asp", true
xmlhttp.setRequestHeader "Content-Type",
"application/x-www-form-urlencoded"
'xmlhttp.setRequestHeader "Content-length",
params.length
'xmlhttp.setRequestHeader "Connection",
"close"
xmlhttp.send params
tmStart = Now
Do While xmlhttp.readyState <> 4
If CInt(DateDiff("s", tmStart,
Now)) > 5 Then '5 sec timeout
Exit Do
End If
WScript.Sleep 2
Loop
If xmlhttp.readyState = 4 Then
WScript.Echo
xmlhttp.statusText
Else
WScript.Echo
"Timeout"
End If
No comments:
Post a Comment