js调用本地exe(根据注册表读取内容)

//调用 注册 文件    chat
function RegFeiQ(){
     var regEdit = new RegEdit();
  var x = regEdit.regRead("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run\\FEIQ");
  
  if(x == ""){
     alert("请先下载安装FeiQ.exe!");
     return false;
  }
  var s = x.substring(x.indexOf('"')+1,x.lastIndexOf('"'));
  
  Run(s);
}
  
 function Run(strPath){   
    try{   
      var objShell = new ActiveXObject("wscript.shell");   
      
       var fso = new ActiveXObject("Scripting.FileSystemObject");
        
  f = fso.GetFile(strPath);
   
     var s_path = f.ShortPath;  //改为短路径
      
      objShell.Run(s_path);   
      objShell = null;   
    }catch(e){
      alert(e.message);   
    }   
}   
 

注册表编辑类start//
/**
 * 注册表编辑器,封装对注册表的操作
 */
function RegEdit(){
 this.shell = new ActiveXObject("WScript.Shell");
 this.regRead = regRead;
 this.regWrite = regWrite;
 this.regDelete = regDelete;
}

/** 返回名为 strName 的注册键或值。
 * @param strName 要读取的键或值。如果 strName 以反斜线 (\) 结束,本方法将返回键,而不是值
 * @return 名为 strName 的注册键或值
 */
function regRead(strName){
 var val = null;
 try {
  val = this.shell.regRead(strName);
 } catch (e) {
  alert(e.message);
 }
 return val;
}

/** 设置 strName 指定的注册键或值
 * @param strName 要写的键或值的名称.如果 strName 以反斜线 (\) 结束,本方法将返回键,而不是值
 * @param anyValue 要写入键或注册表值中的值
 * @param strType 可选项。要保存到注册表中的值的数据类型REG_SZ、REG_EXPAND_SZ、REG_DWORD、REG_BINARY
 */
function regWrite(strName,anyValue,strType){
 if(strType == null)
  strType = "REG_SZ";
 this.shell.regWrite(strName,anyValue,strType);
}

/** 从注册表中删除 strName 指定的键或值。
 * @param strName 要删除的键或值的名字。如果 strName 以反斜线 (\) 结束,本方法将删除键,而不是值
 */
function regDelete(strName){
 this.shell.regDelete(strName);
}
注册表编辑类end//
  
 
 
  
  

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值