Vbscript 错误800A01A8需要对象

Vbscript 错误800A01A8需要对象,vbscript,Vbscript,我有一个VBScript代码,它给我一个错误,表示需要对象 以及第11行和第3字符处的错误800A01A8 代码如下: 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

我有一个VBScript代码,它给我一个错误,表示需要对象 以及第11行和第3字符处的错误800A01A8

代码如下:

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
错误是。

您调暗了BSTR,但初始化了endbStrm:

证据:

>> Dim x
>> With x
>>   .Type = 1
>> End With
>>
Error Number:       424
Error Description:  Object required
>>
使用OptionExplicit可避免此类错误

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