Vbscript 从服务器获取响应文本

Vbscript 从服务器获取响应文本,vbscript,Vbscript,我正在尝试使用Microsoft.XmlHttp获取网站文件夹结构中的文件中的文本,然后将其与本地PC上的版本.txt进行比较。如果相同,它将提示消息它包含相同的版本,否则它将显示相反的内容 URL="http://www.example.org/sites/default/files/version.txt" Set WshShell = WScript.CreateObject("WScript.Shell") Set http = CreateObject("Microsoft.XmlHt

我正在尝试使用Microsoft.XmlHttp获取网站文件夹结构中的文件中的文本,然后将其与本地PC上的
版本.txt
进行比较。如果相同,它将提示消息它包含相同的版本,否则它将显示相反的内容

URL="http://www.example.org/sites/default/files/version.txt"
Set WshShell = WScript.CreateObject("WScript.Shell")
Set http = CreateObject("Microsoft.XmlHttp")
On Error Resume Next
http.open "GET", URL, False
http.send ""
if http.status = 200 Then
    server_version = http.responseText
End if
Set objFSO = CreateObject("Scripting.FileSystemObject") 
Set objClientVersion = objFSO.OpenTextFile("C:\mcgfiles\avp\hash.txt",1)
client_version = objClientVersion.ReadLine

comparison = StrComp(server_version, client_version)
If comparison = 0 Then
    Wscript.Echo "the same"
Else
    Wscript.Echo "not the same"
End If

有点不错,但每次我尝试从服务器更改的内容时,这个脚本仍然会得到旧值:例如,before的值是123456,当我运行脚本时,它会得到123456。当我将值更改为654321并运行此脚本时,它仍然会得到旧值123456。感谢帮助

禁用响应缓存:

http.open "GET", URL, False
http.setRequestHeader "Cache-Control", "no-cache,max-age=0"
http.setRequestHeader "Pragma", "no-cache"
http.send
此外,您可能希望将
ReadLine
替换为
ReadAll
,因为前者只读取本地文件的第一行,而HTTP请求返回整个远程文件