1. 程式人生 > >IE和Firefox下執行exe程式

IE和Firefox下執行exe程式

  1. <a href="javascript:LaunchApp()">Click here to Execute your file</a>
  2. <script>
  3. functionLaunchApp() {
  4. netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
  5. var file=Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
  6. file.initWithPath("D:\\Software\\yourfile.exe");
  1. file.launch();
  2. }
  3. </script>

例子:如果exe帶引數則var args = ["argument1""argument2"]; 

  1. var file = Components.classes["@mozilla.org/file/local;1"]  
  2.                      .createInstance(Components.interfaces.nsILocalFile);  
  3. file.initWithPath("c:\\myapp.exe"
    );  
  4. // create an nsIProcess
  5. var process = Components.classes["@mozilla.org/process/util;1"]  
  6.                         .createInstance(Components.interfaces.nsIProcess);  
  7. process.init(file);  
  8. // Run the process.
  9. // If first param is true, calling thread will be blocked until
  10. // called process terminates.
  11. // Second and third params are used to pass command-line arguments
  12. // to the process.
  13. var args = ["argument1""argument2"];  
  14. process.run(false, args, args.length); 
如:var arguments = ["-h","10.20.65.41","-p","5901","-w","11111111","--title","1111"];


積累:
  1. var WSS = new ActiveXObject("WScript.Shell");  
  2. WSS.RegWrite("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows NT\\CurrentVersion\\Windows\\Device","pdfFactory Pro,winspool,FPP2:");  
	var WSS = new ActiveXObject("WScript.Shell");
	WSS.RegWrite("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows NT\\CurrentVersion\\Windows\\Device","pdfFactory Pro,winspool,FPP2:");

             這個需要是來源於客戶端設定印表機,並直接通過applet進行列印