通过VBScript检查URL是否存在

通过VBScript检查URL是否存在,url,if-statement,vbscript,request,exists,Url,If Statement,Vbscript,Request,Exists,我想要一个vbscript,它可以在不打开任何浏览器的情况下检查URL是否存在。如果存在,则弹出一条消息。 脚本模式应该是这样的:(更简单的脚本,最好的脚本) 这里的常用代码 Url="www.lol.com/letter.txt" 用于检查url是否存在的代码 If exists Msgbox("Success") Else Msgbox("Failed") Wscript.Quit 这个函数应该完成这项工作 function testUrl(url) Set o = Cr

我想要一个vbscript,它可以在不打开任何浏览器的情况下检查URL是否存在。如果存在,则弹出一条消息。 脚本模式应该是这样的:(更简单的脚本,最好的脚本)

这里的常用代码

Url="www.lol.com/letter.txt"
用于检查url是否存在的代码

If exists

Msgbox("Success")

Else

Msgbox("Failed")

Wscript.Quit

这个函数应该完成这项工作

function testUrl(url)
    Set o = CreateObject("MSXML2.XMLHTTP")
    on error resume next
    o.open "GET", url, False
    o.send
    if o.Status = 200 then testUrl = True
    on error goto 0 
end function
称之为使用

if testUrl("http://www.example.com") then
     msgbox "SUCCESS"
else
     msgbox "FAILED" 
end if

好兄弟。。。但avast将此脚本检测为病毒(你不能把它标记为例外吗?