一些背景知识:我们有一个VBScript,用于将数据从报告中下载到CSV文件中。该报告来自SSRS工具。 当宏需要数据时,宏(并且必须)调用此VBScript。 到目前为止,我们在Windows 7中没有遇到任何问题。
我的问题:当我们在Windows 10中使用相同的脚本时,我们收到错误
手术超时。
当宏调用它时(在Windows 10中)它不起作用,但在通过命令提示符执行时起作用。
我的问题:我不明白为什么会出现此问题,并希望将其删除。
调用VBS的VBA代码:
Private Sub create_dump()
Dim x As String
Updt.Show False
With Updt
.Label1 = "Please Wait!!!" & vbCr & vbCr & "Downloading Data...."
.Label1.TextAlign = fmTextAlignCenter
End With
SFilename = "C:\temp\download_Moni.vbs"
Set wshShell = CreateObject("Wscript.Shell")
Set proc = wshShell.exec("wscript " & SFilename & "") 'run VBScript
Do While proc.Status = 0 'Waiting for VBScript to run
DoEvents
Loop
Updt.Hide
End Sub
将数据作为CSV文件下载的脚本VBS。
Set args = WScript.Arguments
Dim lResolve
Dim lConnect
Dim lSend
Dim lReceive
URL = ""
lResolve = (30 * 1000)
lConnect = (60 * 1000)
lSend = (150 * 1000)
lReceive = (150 * 1000)
Dim xHttp: Set xHttp = CreateObject("MSXML2.ServerXMLHTTP.6.0")
Dim bStrm: Set bStrm = CreateObject("Adodb.Stream")
Set xHttp = CreateObject("WinHttp.WinHttpRequest.5.1")
xHttp.SetAutoLogonPolicy 0
xHttp.setTimeouts lResolve, lConnect, lSend, lReceive
xHttp.Open "GET", URL, False 'Open socket to get the website
'======================================
xHttp.Send 'send request **Always get error here when macro calls in Windows 10**
'======================================
With bStrm
.Type = 1 '//binary
.Open
.Write xHttp.responseBody
.savetofile "C:\Ticket\Monitoring.csv", 2 '//overwrite
End With