//产生一个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
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 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");
}
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
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;
}
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;
}
}