如何将批处理文件中写入的dos命令写入javascript

发布于 2024-09-17 20:57:37 字数 501 浏览 4 评论 0原文

我正在使用以下 javascript:

function doPrint(){
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
var exe = Components.classes['@mozilla.org/file/local;1'].createInstance(Components.interfaces.nsILocalFile);
 exe.initWithPath("C:\\temp\\print.bat"); 
exe.launch();
}

print.bat 有以下命令:

lpr -S 192.168.19.211  -P print -o l C:\\Temp\\temp.txt

代码运行良好,但需要 print.bat 存在。

如何将 print.bat 中编写的命令转移到 doPrint 函数中?

I am using the following javascript:

function doPrint(){
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
var exe = Components.classes['@mozilla.org/file/local;1'].createInstance(Components.interfaces.nsILocalFile);
 exe.initWithPath("C:\\temp\\print.bat"); 
exe.launch();
}

print.bat has the following command :

lpr -S 192.168.19.211  -P print -o l C:\\Temp\\temp.txt

the code runs fine , but it requires print.bat to be present.

How can I shift the command written in print.bat into my doPrint function?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

雨巷深深 2024-09-24 20:57:37

看看 https://developer.mozilla.org/en/Code_snippets/Running_applications#Using_nsIProcess

您可以在 initWithPath 调用中使用 lpr 并使用 nsIProcess 使用参数运行它。

Have a look at https://developer.mozilla.org/en/Code_snippets/Running_applications#Using_nsIProcess

You could use lpr in the initWithPath call and use nsIProcess to run it with the parameters.

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