一部のサーバーにpingを実行して結果を出力するVBScriptがあります(このPastebinの完全なコード)。スクリプトの一部には、「お待ちください」というメッセージが表示された IE ウィンドウが表示されますが、何らかの理由で 2 つの IE ウィンドウが開いています (そして、以下のコードで希望どおりにデータが取り込まれています) Quit
。脚本。
これが私に問題を引き起こしている機能です。1行目( 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