dim xHttp: Set xHttp = createobject("microsoft.xmlhttp")
dim bStrm: Set bStrm = createobject("Adodb.Stream")
xHttp.Open "GET", "https://www.website.com/apps/CertMgr.Exe", False
xHttp.Send
with bStrm
.type = 1 '//binary
.open
.write xHttp.responseBody
.savetofile "c:\CertMgr.Exe", 2 '//overwrite
end with
使用上面的代码,我尝试从安全站点下载文件以自动安装安全证书,它在 http 站点上运行良好,但我需要绕过安全错误。有任何想法吗?
最佳答案
您需要从 MSXML2.XMLHTTP 切换到 MSXML2.ServerXMLHTTP 并使用值为 setOption 的 SXH_SERVER_CERT_IGNORE_ALL_SERVER_ERRORS 方法。只需在打开和发送之间进行调用。这是使用新代码更新的示例。
const SXH_SERVER_CERT_IGNORE_ALL_SERVER_ERRORS = 13056
dim xHttp: Set xHttp = createobject("MSXML2.ServerXMLHTTP")
dim bStrm: Set bStrm = createobject("Adodb.Stream")
xHttp.Open "GET", "https://www.website.com/apps/CertMgr.Exe", False
xHttp.setOption 2, SXH_SERVER_CERT_IGNORE_ALL_SERVER_ERRORS
xHttp.Send
with bStrm
.type = 1 '//binary
.open
.write xHttp.responseBody
.savetofile "c:\CertMgr.Exe", 2 '//overwrite
end with
关于windows - vbscript 下载文件(绕过无效证书错误),我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/5096787/