标题: [注册表类] 如何用批处理查找注册表的某个值,并获取上一级的名称? [打印本页]
作者: mokson 时间: 2011-9-9 14:18 标题: 如何用批处理查找注册表的某个值,并获取上一级的名称?
本帖最后由 mokson 于 2011-9-10 00:57 编辑
注册表信息如下:
[HKEY_LOCAL_MACHINE\SOFTWARE\Nokia\App]
“Name”=hex:74,f8,3d,bf,73,79,49
问题:
1:如何定位到指定的注册表 REG_MULTI_SZ (多字符串值类型)的数值?即:hex:74,f8,3d,bf,73,79,49
2:如何获取上一级节点的值?即:[HKEY_LOCAL_MACHINE\SOFTWARE\Nokia\App]
批处理如何写呢?
作者: hfg1977 时间: 2011-9-9 19:48
本帖最后由 hfg1977 于 2011-9-9 20:02 编辑
快速定位注册表,以前写过; 其他问题本论坛多有提及,google吧.- @echo off&setlocal enabledelayedexpansion
- title 快速定位注册表
- ::检查WMI的运行状态
- for /f "tokens=4" %%a in ('sc query winmgmt^|findstr /i "STATE"') do (echo WMI的运行状态:%%~a>con&set "wmirun=%%~a")
- if /i not "%wmirun%"=="RUNNING" (
- rem 记录WMI的原始配置状态
- for /f "tokens=4" %%a in ('sc qc winmgmt^|findstr /i "START_TYPE"') do (echo WMI的原始配置状态:%%~a>con&set "wmicfg=%%~a")
- if /i "!wmicfg!"=="DISABLED" (sc config winmgmt start= AUTO)
- sc start winmgmt
- sc config winmgmt start= !wmicfg!
- )>nul 2>nul
- set "reg_des=HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Applets\Regedit"
- set "reg_Favorites=HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Applets\Regedit\Favorites"
- :start
- set ee=
- set ee=
- cls
- echo ==============================================================
- echo.
- echo · 本程序用于快速定位注册表.
- echo 1. HKCU\……Run
- echo 2. HKLM\……Run
- echo 3. HKLM\……Services 服务设置
- echo · C(c) 把1~3项添加到注册表收藏夹
- echo · S(s) 新建收藏项 (meijia)
- echo · Q(q) 空回车 直接退出
- echo.
- echo · hf-g 2009-08-20 ^<彭城^>
- echo ============================================================
-
- set /p ee=输入^|粘贴要查找的注册表键值:
- if not defined ee goto :eof
- if /i "%ee%"=="q" goto :eof
- if /i "%ee%"=="c" goto :reg_sc
- set ee=%ee:HKCU=HKEY_CURRENT_USER%
- set ee=%ee:HKLM=HKEY_LOCAL_MACHINE%
- if "%ee:~-1%"=="\" set "ee=%ee:~,-1%"
- if "%ee%"=="1" goto :HKCU_Run
- if "%ee%"=="2" goto :HKLM_Run
- if "%ee%"=="3" goto :HKLM_Services
- set ee=%ee:\\=\%
- call:goto_reg %ee%
-
- :HKCU_Run
- set "ee=HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run"
- call:goto_reg %ee%
- :HKLM_Run
- set "ee=HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run"
- call:goto_reg %ee%
- :HKLM_Services
- set "ee=HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services"
- call:goto_reg %ee%
-
- :goto_reg reg_key
- reg add %reg_des% /v "LastKey" /t REG_SZ /d "%ee%" /f
- taskkill /f /im regedit.exe 2>nul
- call start regedit
- goto :start
-
- :reg_sc
- (
- reg add %reg_Favorites% /v "收藏夹" /t REG_SZ /d %reg_Favorites% /f
- reg add %reg_Favorites% /v "HKCU_Run" /t REG_SZ /d "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run" /f
- reg add %reg_Favorites% /v "HKLM_Run" /t REG_SZ /d "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" /f
- reg add %reg_Favorites% /v "服务设置" /t REG_SZ /d "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services" /f
- reg add %reg_Favorites% /v "运行历史记录" /t REG_SZ /d HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\RunMRU /f
- reg add %reg_Favorites% /v "hf'file" /d "HKEY_LOCAL_MACHINE\Software\hf'file" /f
- )>nul&goto :start
- pause
复制代码
作者: mokson 时间: 2011-9-9 20:39
感谢了,我要认真地研究每一行代码!
欢迎光临 批处理之家 (http://bathome.net./) |
Powered by Discuz! 7.2 |