我正在创建一个需要打开 PDF 文档的 HTA 应用程序。我不能假设用户将在他的 PC 上安装 acrobat,如本例所示
WScript(文档)允许您运行命令行应用程序。但我想要的是让 WScript 模拟双击文件。
我希望能够做类似的事情
var wshShell = new ActiveXObject("WScript.Shell");
wshShell.Exec(pdfFilePath); // That does not work
在cmd
中,您可以像这样打开一个文件:start c:\path\to\file.pdf
也许这行得通
wshShell.Exec("start " & pdfFilePath); //do you do string concat like this in wscript?
如果 pdfFile 包含空格,则必须在 pdfFilePath 的开头和结尾添加“和” 更改为: wshShell.Run('cmd /C start '+ '\"' + pdfFile + '\"' ,1,false)
这样做的方法是:
new ActiveXObject("WScript.Shell").Run(pdfFile,1,false);