我有一个 VBScript 可以 ping 一些服务器并输出结果(此Pastebin中的完整代码)。脚本的一部分显示了一个带有“请稍候”消息的 IE 窗口,但由于某种原因,打开了两个 IE 窗口(并按照我希望通过下面的代码填充),但是当我Quit
在结束时只有一个关闭脚本。
这是给我带来麻烦的功能。似乎第一行(objExplorer.Navigate
)正在按要求打开一个窗口,但在此之前Set objExplorer = CreateObject("InternetExplorer.Application")
也打开一个窗口。
有谁知道我怎样才能阻止这种情况发生?谢谢。
' Display the progress box
Set objExplorer = CreateObject("InternetExplorer.Application")
display_progress(objExplorer)
main() ' Do stuff, see Pastebin for full code
close_progress(objExplorer)
output_results() ' Show user the results, see Pastebin for full code
Private Function display_progress(objExplorer)
objExplorer.Navigate "about:blank"
objExplorer.ToolBar = 0
objExplorer.StatusBar = 0
objExplorer.Left = 600
objExplorer.Top = 374
objExplorer.Width = 400
objExplorer.Height = 152
objExplorer.Visible = 1
Dim strText, strButton
strText = "<div id=""text""><p>Please wait, servers are being pinged.</p><p>Results will be displayed as soon as they are ready.</p></div>"
strButton = "<div id=""buttons""><input type=""button"" name=""submit"" value=""Cancel"" onclick=""window.open('', '_self', ''); window.close();"" /><div class=""clear""></div></div>"
objExplorer.Document.Body.Style.Font = "11pt 'Halvetica'"
objExplorer.Document.Body.Style.Cursor = "wait"
objExplorer.Document.Title = "Server ping script"
objExplorer.Document.Body.InnerHTML = strStyle & strText & strButton
End Function
Private Function close_progress(objExplorer)
objExplorer.Document.Body.Style.Cursor = "default"
objExplorer.Quit
End Function