如何使用 WScript.Shell 打开 pdf
我正在创建一个需要打开 PDF 文档的 HTA 应用程序。我不能假设用户将在他的电脑上安装 acrobat,如这个 示例< /a>
WScript (文档)允许您运行命令行应用程序。但我想要的是 WScript 模拟双击文件。
我希望能够做类似的事情
var wshShell = new ActiveXObject("WScript.Shell");
wshShell.Exec(pdfFilePath); // That does not work
I'm creating a HTA application that needs to open PDF document. I cannot assum that the user will have acrobat installed on his PC as in this example
The WScript (documentation) allow you to run a command line application. But what I would like, is for the WScript to simulate a double click on the file.
I would like to be able to do something like
var wshShell = new ActiveXObject("WScript.Shell");
wshShell.Exec(pdfFilePath); // That does not work
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这样做的方法是:
The way to do this is:
在
cmd
中,您可以打开这样的文件:start c:\path\to\file.pdf
也许这有效
In
cmd
, you can open a file like this:start c:\path\to\file.pdf
Maybe this works
如果pdfFile包含空格,则必须在pdfFilePath的开头和结尾添加“和”
更改为: wshShell.Run('cmd /C start '+ '\"' + pdfFile + '\"' ,1,false)
If pdfFile contains space, you must be add " and " into start and end of pdfFilePath
Change to: wshShell.Run('cmd /C start '+ '\"' + pdfFile + '\"' ,1,false)