通过 VBScript 检查 URL 是否存在

Check URL exists or not By VBScript

我想要一个 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