VBS去一个URL在后台 [英] VBS going to a URL in the background

查看:367
本文介绍了VBS去一个URL在后台的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想有我的VB脚本转到后台的URL。它可以打开在后台浏览器,并随后将其关闭。更多的沉默就更好了。我有2个实现,我的机器上工作,但在另一个不工作:

I would like to have my VB script go to a URL in the background. It can open a browser in the background and close it afterwards. The more "silent" the better. I had 2 implementations that work on my machine but doesn't work on another:

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字符串变量。

...where myURL is a string variable containing the URL.

我不明白,为什么无论是上述工程在我的笔记本电脑,但不是在服务器上。任何帮助将是AP preciated。

I can't figure out why either of the above works on my laptop but not on the server. Any help would be appreciated.

推荐答案

如果你正在寻找一个沉默的做法,我建议完全删除的Internet Explorer COM对象,去一个的 XMLHtt prequest 对象

If you're looking for a silent approach I'd suggest to drop the Internet Explorer COM object entirely and go for an XMLHttpRequest object:

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

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

WScript.Echo req.ResponseText

这篇关于VBS去一个URL在后台的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆