若何读取注册表RUN项里面有几个键值[网络技术]
本文“若何读取注册表RUN项里面有几个键值[网络技术]”是由七道奇为您精心收集,来源于网络转载,文章版权归文章作者所有,本站不对其观点以及内容做任何评价,请读者自行判断,以下是其具体内容:
1、批处理:(保存为.bat或.cmd文件)
1、操纵reg query:
@echo off
set r=\Software\Microsoft\Windows\CurrentVersion\Run
for /f "skip=3 delims=" %%a in (’reg query HKLM%r%’) do echo.%%a
echo.&echo.&echo.
for /f "skip=3 delims=" %%a in (’reg query HKCU%r%’) do echo.%%a
pause
2、操纵reg export:
@echo off
md RunInf
pushd RunInf
set r=\Software\Microsoft\Windows\CurrentVersion\Run
>nul reg export HKLM%r% 1
>nul reg export HKCU%r% 2
for /f "skip=2 delims=" %%a in (’type 1’) do echo.%%a
echo.&echo.&echo.
for /f "skip=2 delims=" %%a in (’type 2’) do echo.%%a
popd
rd/s/q RunInf
pause
3、操纵regedit -e:
@echo off
md RunInf
pushd RunInf
set r=\Software\Microsoft\Windows\CurrentVersion\Run
regedit -e 1 Hkey_Local_Machine%r%
regedit -e 2 Hkey_Current_User%r%
for /f "skip=2 delims=" %%a in (’type 1’) do echo.%%a
echo.&echo.&echo.
for /f "skip=2 delims=" %%a in (’type 2’) do echo.%%a
popd
rd/s/q RunInf
pause
2、vbs:(保存为.vbs或.vbe文件)
Const HKEY_LOCAL_MACHINE=&H80000002
Const HKEY_CURRENT_USER=&H80000001
Const sPath="software\microsoft\windows\currentversion\run"
WScript.Echo ListRun(HKEY_LOCAL_MACHINE,sPath)&ListRun(HKEY_CURRENT_USER,sPath)
Function ListRun(intRoot,strKeyPath)
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")
oReg.EnumValues intRoot,strKeyPath,arrValueNames,arrValueTypes
For i=0 To UBound(arrValueNames)
oReg.GetStringValue intRoot, strKeyPath,arrValueNames(i),value
ListRun=ListRun&arrValueNames(i)&", " &value &vbCrLf
Next
End Function
3、js:(保存为.js或.jse文件)
var HKEY_LOCAL_MACHINE = 0x80000002;
var HKEY_CURRENT_USER = 0x80000001;
var sPath="Software\\Microsoft\\Windows\\CurrentVersion\\Run";
WScript.Echo(ListRun(HKEY_LOCAL_MACHINE,sPath)+ListRun(HKEY_CURRENT_USER,sPath));
function ListRun(sRoot,sRegPath) {
var s="",i,count,name,NameAndType;
NameAndType=EnumMethods("EnumValues",sRoot, sRegPath);
count=NameAndType.sNames.ubound();
name=NameAndType.sNames.toArray();
for(i=0;i<=count;i++) s=s+name[i]+", "+GetMethods("GetStringValue",sRoot,sRegPath,name[i]).sValue+"\n";
return s;
}
//摆列键的名称:
function EnumMethods(MethodName,sRoot,sRegPath) {
var oLoc=new ActiveXObject("WbemScripting.SWbemLocator");
var oSvc=oLoc.ConnectServer(null,"root\\default");
var oReg=oSvc.Get("StdRegProv");
var oMethod=oReg.Methods_.Item(MethodName);
var oInParam=oMethod.InParameters.SpawnInstance_();
oInParam.hDefKey=sRoot;
oInParam.sSubKeyName=sRegPath;
var oOutParam=oReg.ExecMethod_(oMethod.Name,oInParam);
return oOutParam;
}
//取键值:
function GetMethods(MethodName,sRoot,sRegPath,strValueName) {
var oLoc=new ActiveXObject("WbemScripting.SWbemLocator");
var oSvc=oLoc.ConnectServer(null, "root\\default");
var oReg=oSvc.Get("StdRegProv");
var oMethod=oReg.Methods_.Item(MethodName);
var oInParam=oMethod.InParameters.SpawnInstance_();
oInParam.hDefKey=sRoot;
oInParam.sSubKeyName=sRegPath;
oInParam.sValueName=strValueName;
var oOutParam = oReg.ExecMethod_(oMethod.Name, oInParam);
return oOutParam;
}
[注解:regedit可以用的windows 2000下面读取注册表键盘,而reg则可以用在windows xp与windows 2003]
以上是“若何读取注册表RUN项里面有几个键值[网络技术]”的内容,如果你对以上该文章内容感兴趣,你可以看看七道奇为您推荐以下文章:
本文地址: | 与您的QQ/BBS好友分享! |