标题: [注册表类] [已解决]批处理如何导出注册表指定的项? [打印本页]
作者: e98123 时间: 2011-5-29 02:37 标题: [已解决]批处理如何导出注册表指定的项?
本帖最后由 e98123 于 2019-2-28 08:15 编辑
set REGFILE=a.reg
set KEYNAME=HKEY_CURRENT_USER\Environment
echo Windows Registry Editor Version 5.00>%REGFILE%
echo [%KEYNAME%]>>%REGFILE%
reg export "%KEYNAME%" export.bak
type export.bak|find /i """TEMP""">>%REGFILE%
1、以上export.bak导出的内容为:
[HKEY_CURRENT_USER\Environment]
"TEMP"=hex(2):25,00,55,00,53,00,45,00,52,00,50,00,52,00,4f,00,46,00,49,00,4c,\
00,45,00,25,00,5c,00,4c,00,6f,00,63,00,61,00,6c,00,20,00,53,00,65,00,74,00,\
74,00,69,00,6e,00,67,00,73,00,5c,00,54,00,65,00,6d,00,70,00,00,00
"TMP"=hex(2):25,00,55,00,53,00,45,00,52,00,50,00,52,00,4f,00,46,00,49,00,4c,00,\
45,00,25,00,5c,00,4c,00,6f,00,63,00,61,00,6c,00,20,00,53,00,65,00,74,00,74,\
00,69,00,6e,00,67,00,73,00,5c,00,54,00,65,00,6d,00,70,00,00,00
2、取TEMP后,在a.reg中只能得到:(只有1行)
"TEMP"=hex(2):25,00,55,00,53,00,45,00,52,00,50,00,52,00,4f,00,46,00,49,00,4c,\
3、请问有什么方法可以完整地得到:(完整3行)
"TEMP"=hex(2):25,00,55,00,53,00,45,00,52,00,50,00,52,00,4f,00,46,00,49,00,4c,\
00,45,00,25,00,5c,00,4c,00,6f,00,63,00,61,00,6c,00,20,00,53,00,65,00,74,00,\
74,00,69,00,6e,00,67,00,73,00,5c,00,54,00,65,00,6d,00,70,00,00,00
PS:
打算做一个注册表修改的玩意,安装时备份导出原来的设置,卸载时再导入备份时的设置,直接导入注册表REG文件比较方便,不打算使用reg add方法。
作者: CrLf 时间: 2011-5-29 10:18
也许可以参考下前几天的帖子:
http://bbs.bathome.net/thread-12530-1-2.html
作者: e98123 时间: 2011-5-29 10:33
我现在不是在导出上有问题,而是要取出标签TEMP,的完整多行内容;
"TEMP"=hex(2):25,00,55,00,53,00,45,00,52,00,50,00,52,00,4f,00,46,00,49,00,4c,\
00,45,00,25,00,5c,00,4c,00,6f,00,63,00,61,00,6c,00,20,00,53,00,65,00,74,00,\
74,00,69,00,6e,00,67,00,73,00,5c,00,54,00,65,00,6d,00,70,00,00,00
作者: CrLf 时间: 2011-5-29 10:44
- @echo off
- for /f "tokens=1* delims==" %%a in (1.txt) do (
- if /i %%~a==temp set "regtmp=%%b"&echo %%a=%%b
- if defined regtmp if "%%b"=="" (
- echo %%a
- ) else set regtmp=
- )
- pause
复制代码
作者: e98123 时间: 2011-5-29 10:56
@echo off
for /f "tokens=1* delims==" %%a in (1.txt) do (
if /i %%~a==temp set "regtmp=%%b"&echo %%a=%%b
if defined regtmp if "%%b"=="" (
echo %%a
) else set regtmp=
)
pause
zm900612 发表于 2011-5-29 10:44
假设1.TXT的内容为:
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Environment]
"TEMP"=hex(2):25,00,55,00,53,00,45,00,52,00,50,00,52,00,4f,00,46,00,49,00,4c,\
00,45,00,25,00,5c,00,4c,00,6f,00,63,00,61,00,6c,00,20,00,53,00,65,00,74,00,\
74,00,69,00,6e,00,67,00,73,00,5c,00,54,00,65,00,6d,00,70,00,00,00
"TMP"=hex(2):25,00,55,00,53,00,45,00,52,00,50,00,52,00,4f,00,46,00,49,00,4c,00,\
45,00,25,00,5c,00,4c,00,6f,00,63,00,61,00,6c,00,20,00,53,00,65,00,74,00,74,\
00,69,00,6e,00,67,00,73,00,5c,00,54,00,65,00,6d,00,70,00,00,00
贴出的代码运行后无任何返回?
作者: e98123 时间: 2011-5-29 11:14
我有个思路不知行不行得通?
以"TEMP"=为起始,"TMP"开头的"为终止,这样的语名应该怎么写呢?
作者: CrLf 时间: 2011-5-29 11:43
- @echo off
- setlocal enabledelayedexpansion
- for /f "tokens=1* delims==" %%a in (1.txt) do (
- if "%%b" neq "" set regtmp=
- if defined regtmp echo %%a
- if /i %%~a==temp (set "regtmp=."&echo %%a=%%b)
- )
- pause
复制代码
作者: e98123 时间: 2011-5-29 12:50
@echo off
setlocal enabledelayedexpansion
for /f "tokens=1* delims==" %%a in (1.txt) do (
if "%%b" neq "" set regtmp=
if defined regtmp echo %%a
if /i %%~a==temp (set "regtmp=."&echo %%a ...
zm900612 发表于 2011-5-29 11:43
只显示了请按任意键继续......
作者: CrLf 时间: 2011-5-29 12:57
测试过的,这样还不行那我也不知道了
欢迎光临 批处理之家 (http://www.bathome.net/) |
Powered by Discuz! 7.2 |