设置打印机

  <SCRIPT language="javascript">
  /*
  <OBJECT id="WSNetwork" style="DISPLAY: none" classid="clsid:093FF999-1EA0-4079-9525-9614C3504B74" viewastext>
  </OBJECT>
  <OBJECT id="WSHShell" style="DISPLAY: none" classid="clsid:72C24DD5-D70A-438B-8A42-98424B88AFB8" viewastext>
  </OBJECT>
  var WSHShell = new ActiveXObject("WScript.Shell");
  var WshSysEnv=WSHShell.Environment("SYSTEM");
  var strNT = "HKEY_CURRENT_USER\\Software\\Microsoft\\Windows NT\\CurrentVersion\\Windows\\Device";
  var str98 = "HKEY_CURRENT_CONFIG\\System\\CurrentControlSet\\Control\\Print\\Printers\\Default";
  var strDefault,defaultPrinter;
  if(WshSysEnv("OS") == "Windows_NT")
  {
   //if NT
   strDefault = strNT;
   defaultPrinter = WSHShell.RegRead(strDefault);
   defaultPrinter = defaultPrinter.split(",")[0];
  }
  else
  {
   strDefault = str98;
   defaultPrinter = WSHShell.RegRead(strDefault);
  }
  
  var strCurrentPrinter;
  if(WSNetwork.ComputerName == "maoxiaohua")
  {
   strCurrentPrinter = "EPSONEPL";
  }
  else
  {
   strCurrentPrinter = "\\\\maoxiaohua\\EPSONEPL";
   
  }
  WSNetwork.SetDefaultPrinter(strCurrentPrinter);
  */
  

  var OLECMDID_PRINT = 6;
  var OLECMDEXECOPT_DONTPROMPTUSER = 2;
  var OLECMDEXECOPT_PROMPTUSER = 1;
  WebBrowser1.ExecWB(OLECMDID_PRINT, 6);
  
  window.setTimeout("window.opener = null;window.close();",1500);
  //window.setTimeout("WSNetwork.SetDefaultPrinter(defaultPrinter);window.opener = null;window.close();",1500);
  </SCRIPT>

posted @ 2009-02-06 14:17  南守拥  阅读(346)  评论(0编辑  收藏  举报