0

您好我正在尝试创建一个通过 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"
4

1 回答 1

2

令我惊讶的是,您是 vbscript 的新手,却选择了那种语言来做这些事情,vbscript 不太适合这种工作,而且 vbscript 的日子已经算多了,如果您想使用程序语言,ruby 会是更好的选择如果你只是想自动化你最好使用http://www.autohotkey.com/

无论如何,像这样它应该在 vbscript 中工作。"" 表示字符串中的单个 "。

Set WshShell = CreateObject("WScript.Shell")
WshShell.Run """g:\path with spaces\thepdf.pdf"""
于 2012-06-25T21:49:28.743 回答