⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 scaner.txt

📁 javascript控制扫描仪 javascript控制扫描仪 javascript控制扫描仪
💻 TXT
字号:
关于客户端控制扫描仪的javascript收藏
新一篇: 客户端控制word | 旧一篇: 关于从数据库读取IMG并生成图片
var tiffloder = null;

var ttiffile = null;
var ftpsvr = "172.16.6.22";

var uname = "cqy";

var pwd = "1";

var pimsfloder = "c:\\pims\\";

var kodakimg = "C:\\Kodakimg\\KODAKIMG.EXE ";
var ActiveToSee = false;

  
  function openScanner(sender,tiffile,source)
  {
   var sv = sender.value;
   sender.disabled = true;
   sender.value = "正在扫描...";
 
   var descfile = getFileName();
   var ttif = downloadfromftp(ftpsvr,uname,pwd,tiffile);
   
   exec(kodakimg + ttif, 3);
   
   uploadtoftp(ftpsvr, uname, pwd, ttif, descfile);
   
   if( IsExist(descfile))
   {
   
    finishScan(descfile); 
    addfujian(descfile,source);
   }
   else
   {
    alert("上传文件失败");
   }
   sender.disabled = false;
   sender.value = sv;
  }

  //返回一个在floder文件夹下的临时文件名,fso是一个Scripting.FileSystemObject对象。注意:floder必须以"\"结尾
  function getTempFile(floder, fso)
  {
   fso = getfso(fso);
    
   if( !fso.FolderExists(floder) )
   {
    //此命令必须启动cmd命令扩展功能
    exec("cmd /c md " + floder, 0);
   }
     
   var tf = floder + fso.GetTempName();
   return tf.replace(/\./g, "_");
  }

  //下载ftp服务器descpath的tif文件到本地,返回本地的文件名
  function downloadfromftp(ftpserverip, username, password, descpath)
  {    
   var ttif = null;
   var fso = getfso(fso);
 
   
   if(ActiveToSee)
   {    
    tiffloder = getTempFile(pimsfloder, fso) + "\\";
   
    var tftp = getTempFile(tiffloder, fso);
  
    ttif = getTempFile(tiffloder, fso) + ".tif";
   
    //以改写方式打开
    var tfile = fso.OpenTextFile(tftp, 2, true);
   
    tfile.WriteLine("open " + ftpserverip)
    tfile.WriteLine(username);
    tfile.WriteLine(password);
    tfile.WriteLine("get " + descpath + " " + ttif); 
    tfile.WriteLine("quit");  
    tfile.Close();
    
    //执行下载指令
    exec("ftp -s:" + tftp, 0);
    
    ////删除临时ftp下载指令文件
    //exec("cmd /c del " + tftp);
   }
   
   return ttif;
  }  

  //获取上传到ftp服务器descpath文件到本从srcpath的ftp指令文件
  function uploadtoftp(ftpserverip, username, password, srcpath, descpath)
  {  
    var fso = getfso(fso);
    
    if(ActiveToSee)
    {  
     var tftp = getTempFile(tiffloder, fso);
     
     //以改写方式打开
     var tfile = fso.OpenTextFile(tftp, 2, true);
     
     tfile.WriteLine("open " + ftpserverip);
     tfile.WriteLine(username);
     tfile.WriteLine(password);
     tfile.WriteLine("put " + srcpath + " " + descpath); 
     tfile.WriteLine("quit");  
     tfile.Close();
       
     //执行上传指令
     exec("ftp -s:" + tftp);
    }
  }
  
  

  //在客户端执行一个command命令
  function exec(command, windowStyle)
  {
      //alert(command);
   var ret = true;
   try
   {
    var wsh = new ActiveXObject('WScript.Shell');
    //if (wsh) wsh.Run(command, 0, true);
    if (wsh) wsh.Run(command, windowStyle , true);
    wsh = null;
   }
   catch(ee)
   {
    ret = false;
    alert("客户端调用WScript.Shell出错");  
    throw ee;
   }
   return ret;
  }

  function getfso(fso)
  {
   try
   {
    if(fso == null)
    {
     fso = new ActiveXObject("Scripting.FileSystemObject");
     ActiveToSee = true;
    }
    return fso;
   }
   catch(ee){}
   return null;
  } 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -