标题: [文本处理] 注册表REG文件中字符串的替换 [打印本页]
作者: xiaofeixiahk 时间: 2008-9-20 03:17 标题: 注册表REG文件中字符串的替换
有一个注册表文件,文件名为test.reg,内容如下:
我的问题是如何利用批处理语句来实现替换"[HKEY_LOCAL_MACHINE\sam\sam\domains\account\users\000001F4]"这一行的最后的数字"4"为"5"。 我只知道用for循环能实现,也懂得一些用法,另外,把""V"=hex:00,00,00,00,bc,00,00,00,02,00,01,00,bc,00,00,00,1a,00,00,00,00,00,00,\"这一行及此行下的所有行都删除掉。
希望前辈在给出代码的同时能够指点下具体的实现方法,授人与不如授人渔嘛,感激不尽!
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\sam\sam\domains\account\users\000001F4]
"F"=hex:02,00,01,00,00,00,00,00,52,5d,73,72,44,1a,c9,01,00,00,00,00,00,00,00,\
00,ac,1a,cd,a9,8b,b7,c8,01,00,00,00,00,00,00,00,00,c4,cf,c0,5e,44,1a,c9,01,\
f4,01,00,00,01,02,00,00,14,02,00,00,00,00,00,00,00,00,8a,00,01,00,00,00,00,\
00,00,00,00,00,00,00
"V"=hex:00,00,00,00,bc,00,00,00,02,00,01,00,bc,00,00,00,1a,00,00,00,00,00,00,\
00,d8,00,00,00,00,00,00,00,00,00,00,00,d8,00,00,00,0a,00,00,00,00,00,00,00,\
e4,00,00,00,00,00,00,00,00,00,00,00,e4,00,00,00,00,00,00,00,00,00,00,00,e4,\
00,00,00,06,00,00,00,00,00,00,00,ec,00,00,00,00,00,00,00,00,00,00,00,ec,00,\
00,00,00,00,00,00,00,00,00,00,ec,00,00,00,00,00,00,00,00,00,00,00,ec,00,00,\
00,00,00,00,00,00,00,00,00,ec,00,00,00,15,00,00,00,a8,00,00,00,04,01,00,00,\
08,00,00,00,01,00,00,00,0c,01,00,00,04,00,00,00,00,00,00,00,10,01,00,00,14,\
00,00,00,00,00,00,00,24,01,00,00,04,00,00,00,00,00,00,00,28,01,00,00,04,00,\
00,00,00,00,00,00,01,00,14,80,9c,00,00,00,ac,00,00,00,14,00,00,00,44,00,00,\
00,02,00,30,00,02,00,00,00,02,c0,14,00,44,00,05,01,01,01,00,00,00,00,00,01,\
00,00,00,00,02,c0,14,00,ff,ff,1f,00,01,01,00,00,00,00,00,05,07,00,00,00,02,\
00,58,00,03,00,00,00,00,00,14,00,5b,03,02,00,01,01,00,00,00,00,00,01,00,00,\
00,00,00,00,18,00,ff,07,0f,00,01,02,00,00,00,00,00,05,20,00,00,00,20,02,00,\
00,00,00,24,00,44,00,02,00,01,05,00,00,00,00,00,05,15,00,00,00,23,5f,63,6b,\
be,04,3e,32,f8,9f,b4,74,f4,01,00,00,01,02,00,00,00,00,00,05,20,00,00,00,20,\
02,00,00,01,02,00,00,00,00,00,05,20,00,00,00,20,02,00,00,41,00,64,00,6d,00,\
69,00,6e,00,69,00,73,00,74,00,72,00,61,00,74,00,6f,00,72,00,00,00,fb,7c,df,\
7e,a1,7b,06,74,58,54,28,00,63,00,3a,00,5c,00,ff,ff,ff,ff,ff,ff,ff,ff,ff,ff,\
ff,ff,ff,ff,ff,ff,ff,ff,ff,ff,ff,ff,ff,aa,ab,ad,01,02,00,00,07,00,00,00,01,\
00,01,00,01,00,01,00,ac,6f,da,cf,20,a6,2d,89,8a,5e,0a,cd,c2,62,9b,5d,01,00,\
01,00,01,00,01,00
作者: pusofalse 时间: 2008-9-20 04:25
- @echo off
- type test.reg|wfr /r:"4\]$" /t:"5\]"|wfr /rnnlic:"00\s\"V\".*" /t:"00">tmp.txt
- wfr tmp.txt /any /encout:ucs-2
- move tmp.txt test.reg
复制代码
wfr.exe:http://bbs.bathome.net/thread-1909-1-1.html
[ 本帖最后由 pusofalse 于 2008-9-20 04:56 编辑 ]
作者: zqz0012005 时间: 2008-9-20 07:59
你的注册表项应该不只这么一点儿吧?- @echo off
- setlocal enabledelayedexpansion
- cd.>output.txt
- set v="V"
- for /f "delims=" %%i in ('type a.reg^|findstr /n .*') do (
- set "var=%%i"
- set var=!var:*:=!
- if defined var set var=!var:000001F5]=000001F4]!
- if "!var:~,3!"=="%V%" set flag=1
- if not defined flag echo.!var!>>output.txt
- if "!var:~-2!"=="00" (set flag=)
- )
复制代码
作者: wxcute 时间: 2008-9-20 12:42
你是想做隐藏帐户吧,呵呵,不要干坏事阿。。。。
作者: 无忧 时间: 2017-5-17 14:01
回复 4# wxcute
这是啥意思啊?全是一组一组的数字……
作者: zb848 时间: 2017-5-17 16:36
你删除一这个键值,再加一个改了的键值,不简单多了
不用这么复杂
欢迎光临 批处理之家 (http://www.bathome.net/) |
Powered by Discuz! 7.2 |