js 注册表

 
//产生一个WScript.Shell对象,它具有操作注册表、执行命令行等能力
var obj = new ActiveXObject("WScript.Shell");
//从Explorer表项中读出TestValue的值
var testValue = obj.RegRead("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer\\TestValue");
//向Explorer表项写入新键:名为TestValue,值为1,类型为REG_SZ
obj.RegWrite("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer\\TestValue","1","REG_SZ");
//向Explorer表项写入新表项:名为TestValue,默认值为空,类型为REG_SZ
obj.RegWrite("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer\\TestValue\\","","REG_SZ");
//删除Explorer表项中名为TestValue的键
obj.RegDelete("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer\\TestValue");
//删除Explorer表项中名为TestValue的表项及其子键
obj.RegDelete("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer\\TestValue\\");
可以看到,用WScript.Shell操作注册表时,就是用"\\"来区分操作对象是表项还是键的。
用这种方法操作客户端注册表要求客户端的浏览器安全设置中允许"运行未签名的ActiveX脚本",否则不会有效果。这是显然的,不然就病毒泛滥了。
 
 
 
 
 
 
 
function wirte_com(com_port)
 Dim OperationRegistry
 Set OperationRegistry=CreateObject("WScript.Shell")
 OperationRegistry.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\NMDL_ICK\COM",com_port
end function
function read_com()
   Dim OperationRegistry
      Set OperationRegistry=CreateObject("WScript.Shell")
      Dim Read_Data
      Read_Data=OperationRegistry.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\NMDL_ICK\COM")
   read_com=Read_Data
end function
******************************************
function write_com(com_port){
var obj = new ActiveXObject("WScript.Shell");
obj.RegWrite("HKEY_LOCAL_MACHINE\\SOFTWARE\\NMDL_ICK\\COM",com_port,"REG_SZ");
}
function read_com(){
var obj = new ActiveXObject("WScript.Shell");
obj.RegRead("HKEY_LOCAL_MACHINE\\SOFTWARE\\NMDL_ICK\\COM");
}
 
********************************************
function read_port1()
 Dim OperationRegistry
    Set OperationRegistry=CreateObject("WScript.Shell")
    Dim Read_Data1,Read_Data2
    on error resume next
  set ws=CreateObject("wscript.shell")
  k=ws.regread("HKEY_LOCAL_MACHINE\SOFTWARE\NMDL_ICK\COM")
 if err.number=-2147024894 then
  Dim OperationRegistry1
  Set OperationRegistry1=CreateObject("WScript.Shell")
  Default=OperationRegistry1.RegRead("HKEY_LOCAL_MACHINE\\")
  OperationRegistry1.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\NMDL_ICK\COM","1"
  read_port1=1
 else
  Read_Data=OperationRegistry.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\NMDL_ICK\COM")
  read_port1=Read_Data 
 end if
end function
____________________________________________________

function read_port1(){
  var obj = new ActiveXObject("WScript.Shell");
  var read_port;
  if(主键不存在){
  
   obj.RegWrite("HKEY_LOCAL_MACHINE\\SOFTWARE\\NMDL_ICK\\COM","1","REG_SZ");
   return 1;
  }else{
   read_port=obj.RegRead("HKEY_LOCAL_MACHINE\\SOFTWARE\\NMDL_ICK\\COM");
   return read_port;
  }
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值