您好我正在尝试创建一个脚本,通过vbscript打开各种互联网页面和程序,但我很难打开位于网络驱动器上的pdf文件,香港专业教育学院尝试了一堆命令,但无法获得文件打开,所以任何帮助将不胜感激:)
Set IE = CreateObject("InternetExplorer.Application")
set WshShell = WScript.CreateObject("WScript.Shell")
IE.Navigate "https://websiteaddress.com
IE.Visible = True
Wscript.Sleep 3000
WshShell.SendKeys "text"
WshShell.SendKeys "{ENTER}"
Wscript.Sleep 3000
WshShell.SendKeys "text"
WshShell.Sendkeys "{TAB}"
WshShell.Sendkeys "{TAB}"
WshShell.Sendkeys "text"
WshShell.SendKeys "{ENTER}"
Wscript.Sleep 3000
WshShell.SendKeys "{TAB}"
WshShell.SendKeys "{TAB}"
WshShell.SendKeys "{ENTER}"
Wscript.Sleep 3000
WshShell.SendKeys "{TAB}"
WshShell.SendKeys "{TAB}"
WshShell.SendKeys "{TAB}"
WshShell.SendKeys "{TAB}"
WshShell.SendKeys "{ENTER}"
Wscript.Sleep 3000
WshShell.SendKeys "{TAB}"
WshShell.SendKeys "{TAB}"
WshShell.SendKeys "{TAB}"
WshShell.SendKeys "{TAB}"
WshShell.SendKeys "{TAB}"
WshShell.SendKeys "{TAB}"
WshShell.SendKeys "{ENTER}"
Wscript.Sleep 3000
WshShell.SendKeys "%{TAB}"
WshShell.SendKeys "%{F4}"
Wscript.Sleep 3000
WshShell.SendKeys "%{TAB}"
IE.Navigate "https://websiteaddress.com"
IE.Visible = True
Wscript.Sleep 3000
WshShell.SendKeys "text"
WshShell.SendKeys "{ENTER}"
Wscript.Sleep 3000
WshShell.Run "H:\Shortcuts /k dir *.*"
WshShell.Run "Notepad.exe"
Wscript.Sleep 3000
WshShell.Run "calc.exe"
我对vbscripting很新,但我尝试了以下两行,但都没有工作;
WshShell.Run "G:\pathtofile\thepdf.pdf"
WshShell.Run "NET USE G: \\server\share\thepdf.pdf"
答案 0 :(得分:2)
令我惊讶的是你是vbscript的新手,但选择那种语言来做这些事情,vbscript不适合这种工作,并且计算vbscript的日子,如果你想使用ruby将是一个更好的选择一种程序语言,如果你只想自动化,你可以使用http://www.autohotkey.com/
无论如何,像这样它应该在vbscript中工作。 “”表示字符串中的单个“。
Set WshShell = CreateObject("WScript.Shell")
WshShell.Run """g:\path with spaces\thepdf.pdf"""