Browser 使用vbscript在可变页面上打开浏览器
我正在尝试编写一点VBScript来打开特定网页上的浏览器。最终,每个脚本的这个网页都是唯一的。目前,我有以下有效的代码:Browser 使用vbscript在可变页面上打开浏览器,browser,vbscript,Browser,Vbscript,我正在尝试编写一点VBScript来打开特定网页上的浏览器。最终,每个脚本的这个网页都是唯一的。目前,我有以下有效的代码: Dim objShell objShell = CreateObject("Shell.Application") objShell.ShellExecute("C:\Program Files (x86)\Google\Chrome\Application\chrome.exe", "www.google.ie", "", "", 1) 但我想让以下各项发挥作用: D
Dim objShell
objShell = CreateObject("Shell.Application")
objShell.ShellExecute("C:\Program Files (x86)\Google\Chrome\Application\chrome.exe", "www.google.ie", "", "", 1)
但我想让以下各项发挥作用:
Dim iURL As String
Dim objShell
iURL = "www.google.ie"
objShell = CreateObject("Shell.Application")
objShell.ShellExecute("C:\Program Files (x86)\Google\Chrome\Application\chrome.exe", iURL, "", "", 1)
知道我做错了什么吗?任何帮助都将不胜感激。No
As String
由于VBScript不是强类型,因此在创建COM对象实例时需要集
,方法调用周围没有paren
Dim iURL
Dim objShell
iURL = "www.google.ie"
set objShell = CreateObject("Shell.Application")
objShell.ShellExecute "chrome.exe", iURL, "", "", 1
或者如果chrome是默认的
set objShell = CreateObject("WScript.Shell")
objShell.run(iURL)
能否在“objShell.ShellExecute”中插入“Call”前缀
对于IE:
'Call objShell.ShellExecute("iexplore.exe", iURL, "", "", 1)
For more info below code also works,
Dim objShell
Set objShell = CreateObject("Shell.Application")
铬:
iURL = "www.google.com"
'objShell.ShellExecute "chrome.exe", iURL, "", "", 1
即:
我发现最简单的方法是:
set WshShell=WScript.CreateObject("WScript.Shell")
WshShell.run "chrome.exe"
WScript.sleep 400
WshShell.sendkeys "URL HERE"
WshShell.sendkeys "{ENTER}"
仅供参考,您可以通过以下操作关闭chrome:
WshShell.sendkeys "%{F4}"
我正在使用visual studio express 2012 for web,它不断删除集合并将其添加回括号中。我用你推荐的方法尝试了其他方法,但得到了同样的结果。变量未被使用,但直接字符串将起作用。作为一种改进,您可以使用:
oShell.ShellExecute“chrome.exe”、“&iURL&”、“、”、“,”,1
(将允许传递按空格拆分的参数而不对其进行编码)发现问题是由启动VBScript的外部程序引起的。谢谢你的帮助Alex K.希望我没有打字错误
set WshShell=WScript.CreateObject("WScript.Shell")
WshShell.run "chrome.exe"
WScript.sleep 400
WshShell.sendkeys "URL HERE"
WshShell.sendkeys "{ENTER}"
WshShell.sendkeys "%{F4}"
Sub RickRoller()
Dim counter, myNum, objShell, iURL
counter = 0
myNum = 100
Do Until myNum = 1
myNum = myNum - 1
counter = counter + 1
Set WshShell = CreateObject("WScript.Shell")
WshShell.SendKeys(chr(&hAF))
Loop
set objShell = CreateObject("WScript.Shell")
iURL = "https://youtu.be/oHg5SJYRHA0?autoplay=1&t=44"
objShell.run(iURL)
End Sub
RickRoller()