如何使用 WScript.Shell 打开 pdf

发布于 2024-11-28 23:59:43 字数 484 浏览 6 评论 0原文

我正在创建一个需要打开 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

君勿笑 2024-12-05 23:59:44

这样做的方法是:

new ActiveXObject("WScript.Shell").Run(pdfFile,1,false);

The way to do this is:

new ActiveXObject("WScript.Shell").Run(pdfFile,1,false);
长途伴 2024-12-05 23:59:43

cmd中,您可以打开这样的文件:start c:\path\to\file.pdf

也许这有效

wshShell.Exec("start " & pdfFilePath); //do you do string concat like this in wscript?

In cmd, you can open a file like this: start c:\path\to\file.pdf

Maybe this works

wshShell.Exec("start " & pdfFilePath); //do you do string concat like this in wscript?
謸气贵蔟 2024-12-05 23:59:43

如果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)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文