我在 Server 2008 R2 机器上运行了这个 VBScript,它运行良好,可以正常打印到默认打印机。
我已将脚本移至 Server 2012 R2 机器,但无法打印。
Dim rs
Set rs = CreateObject("ADODB.Recordset")
Dim strsql
strsql="select orders_htmlfiles.id, replace(name,'\','/') as newname from orders_htmlfiles left join orders on orders_htmlfiles.ordernumber=orders.ordernumber "
strsql= strsql & " where printed=0 "
rs.open strsql, adoConProdRead
Dim IE
Dim URL
Set IE = CreateObject("InternetExplorer.Application")
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
Do while not rs.eof
If fso.FileExists(rs("newname")) Then
URL="file:///"+rs("newname")
IE.Visible = false
IE.Navigate URL
While IE.Busy
WScript.Sleep 100
Wend
IE.ExecWB 6, 2
WScript.Sleep 1000
strsqlupdate="Update orders_htmlfiles set printed=1, printdatetime='" & now & "' where id=" & rs("id")
Set objExec = adoConProdRead.Execute(strsqlupdate)
WScript.Sleep 10000
Else
'msgbox "file not found"
End if
rs.movenext
Loop
rs.close
Set rs=Nothing
IE.Quit