2
votes

I have a VBScript code that gives me an error that says "Object required" and error 800A01A8 at row 11 and character 3.

Here is the code:

Dim strWebsite

strWebsite = "78.72.111.138:80"

If PingSite( strWebsite ) Then
    Dim xHttp: Set xHttp = CreateObject("Microsoft.XMLHTTP")
    Dim bStrm: Set endbStrm = CreateObject("Adodb.Stream")
    xHttp.Open "GET", "http://?/batch/down.php", False
    xHttp.Send
    With bStrm
        .Type = 1 '//binary
        .Open
        .Write xHttp.responseBody
        .SaveToFile "link.txt", 2 '//overwrite
    End With
Else
End If

Function PingSite( myWebsite )
    Dim intStatus, objHTTP

    Set objHTTP = CreateObject( "WinHttp.WinHttpRequest.5.1" )

    objHTTP.Open "GET", "http://" & myWebsite & "/", False
    objHTTP.SetRequestHeader "User-Agent", _
        "Mozilla/4.0 (compatible; MyApp 1.0; Windows NT 5.1)"

    On Error Resume Next

    objHTTP.Send
    intStatus = objHTTP.Status

    On Error Goto 0

    If intStatus = 200 Then
        PingSite = True
    Else
        PingSite = False
    End If

    Set objHTTP = Nothing
End Function

the error is.

1

1 Answers

4
votes

You Dim bStrm, but initialize endbStrm:

dim bStrm: Set endbStrm = createobject("Adodb.Stream")

Evidence:

>> Dim x
>> With x
>>   .Type = 1
>> End With
>>
Error Number:       424
Error Description:  Object required
>>

Use Option Explicit to avoid such blunders.