views:

36

answers:

1

Hi , 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?

A: 

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.

Bruno