1

我想让我的 VB 脚本转到后台的 URL。它可以在后台打开浏览器,然后关闭它。越“沉默”越好。我有 2 个可以在我的机器上运行但不能在另一个机器上运行的实现:

Set WshShell = WScript.CreateObject("WScript.Shell") 
Return = WshShell.Run("iexplore.exe " &  myURL, 1) 

这是另一个:

Set objExplorer = WScript.CreateObject _
("InternetExplorer.Application", "IE_")
objExplorer.Navigate myURL
'Determines if the window is visible or not
objExplorer.Visible = 0
'Suspend the script for 1 minute
WScript.Sleep 6000
'Close the IE (instantiated) window
objExplorer.quit

...其中 myURL 是包含 URL 的字符串变量。

我无法弄清楚为什么上述任何一个都适用于我的笔记本电脑但不适用于服务器。任何帮助,将不胜感激。

4

2 回答 2

5

如果您正在寻找一种静默方法,我建议您完全删除 Internet Explorer COM 对象并寻找一个XMLHttpRequest对象:

myURL = "http://www.google.com/"

Set req = CreateObject("MSXML2.XMLHTTP.6.0")
req.Open "GET", myURL, False
req.Send

WScript.Echo req.ResponseText
于 2013-02-12T15:25:15.577 回答
-1
Set WshShell = WScript.CreateObject("WScript.Shell") 
Return = WshShell.Run("iexplore.exe " &  myURL, 1) 
WScript.Sleep 10000
WshShell.SendKeys "{F6}"
WScript.Sleep 500
WshShell.SendKeys "y"
WScript.Sleep 500
WshShell.SendKeys "o"
WScript.Sleep 500
WshShell.SendKeys "u"
WScript.Sleep 500
WshShell.SendKeys "t"
WScript.Sleep 500
WshShell.SendKeys "u"
WScript.Sleep 500
WshShell.SendKeys "b"
WScript.Sleep 500
WshShell.SendKeys "e"
WScript.Sleep 500
WshShell.SendKeys "{ENTER}"
WScript.Sleep 500
于 2013-11-29T03:29:16.583 回答