我是靠谱客的博主 香蕉冬日,最近开发中收集的这篇文章主要介绍IE和Firefox下执行exe程序,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

IE 下执行exe程序 (ActiveX)

  1. <a href="javascript:LaunchApp()">Click here to Execute your file</a>
  2. <script>
  3. function LaunchApp() {
  4. if (!document.all) {
  5. alert ("This ActiveXObject is only available for Internet Explorer");
  6. return;
  7. }

  8. var ws = new ActiveXObject("WScript.Shell");
  9. ws.Exec("D:\Software\youfile.exe");
  10. }
  11. </script>

 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.   
  5. // create an nsIProcess  
  6. var process = Components.classes["@mozilla.org/process/util;1"]  
  7.                         .createInstance(Components.interfaces.nsIProcess);  
  8. process.init(file);  
  9.   
  10. // Run the process.  
  11. // If first param is true, calling thread will be blocked until  
  12. // called process terminates.  
  13. // Second and third params are used to pass command-line arguments  
  14. // to the process.  
  15. var args = ["argument1""argument2"];  
  16. 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进行打印

最后

以上就是香蕉冬日为你收集整理的IE和Firefox下执行exe程序的全部内容,希望文章能够帮你解决IE和Firefox下执行exe程序所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(60)

评论列表共有 0 条评论

立即
投稿
返回
顶部