标题: [求助]用系统SID值替换注册表SID值
[打印本页]
作者: hgx126
时间: 2008-9-13 00:33
标题: [求助]用系统SID值替换注册表SID值
我导出了一个注册表文件,以便我重装系统后快速恢复设置。可重装系统后,系统的SID值发生变化。我想从系统中获取SID值,再替换已经导出的注册表文件。
SID值即注册表中“HKEY_USERS\
S-1-5-21-××××××××××-××××××××××-××××××××××-×××\”中的红色部分。
比如我导出的注册表文件为Win.reg,部份内容为:
Windows Registry Editor Version 5.00
; 2008-9-12 22:20:22
[HKEY_USERS\
S-1-5-21-1409082233-1563985344-1417001333-500\Software\Microsoft\Windows\CurrentVersion\Explorer]
"ShellState"=hex(03):24,00,00,00,35,ac,01,00,00,00,00,00,00,00,00,00,00,00,\
00,00,01,00,00,00,0d,00,00,00,00,00,00,00,00,00,00,00
[HKEY_USERS\
S-1-5-21-1409082233-1563985344-1417001333-500\Software\Microsoft\Windows\CurrentVersion\Explorer\SmallIcons]
"SmallIcons"="no"
[HKEY_USERS\
S-1-5-21-1409082233-1563985344-1417001333-500\Software\Microsoft\Windows\CurrentVersion\Explorer\Streams]
"Settings"=hex(03):08,00,00,00,04,00,00,00,01,00,00,00,00,77,7e,13,73,35,cf,\
11,ae,69,08,00,2b,2e,12,62,04,00,00,00,01,00,00,00,43,00,00,00
我现在就是想编一个批处理,用系统中获取的SID值替换此注册表文件中的SID值(红色部分),然后导入系统。求高手帮忙。
[
Last edited by hgx126 on 2008-9-13 at 12:37 AM ]
作者: s11ss
时间: 2008-9-13 01:50
@set SID=S-1-5-21-1409082233-1563985344-1417001333-500
@set reg=win.reg
@set SID2=0-0-0-0-0-0-0-0
@set reg2=win2.reg
@for /f "delims=" %%a in (%reg%) do @set s=%%a&call echo %%s:%SID%=%SID2%%%>>%reg2%
作者: hgx126
时间: 2008-9-13 09:57
首先感谢S11SS.
不过我要是SID2从系统中获取,不是0-0-0-0-0-0-0-0.还求帮忙.
作者: HAT
时间: 2008-9-13 10:05
标题: Re 3楼
@echo off
for /f "tokens=2 delims=\" %%a in ('reg query HKEY_USERS^|findstr /i "S-1-5-21-"') do (
set sid=%%a
goto :show
)
goto :eof
:show
echo 你的sid是:%sid%
作者: hgx126
时间: 2008-9-13 13:06
谢谢两位。
我综合两位的,结果如下:
@echo off
@set SID=S-1-5-21-1409082233-1563985344-1417001333-500
@set reg=win.reg
@for /f "tokens=2 delims=\" %%a in ('reg query HKEY_USERS^|findstr /i "S-1-5-21-"') do (
set sid2=%%a
goto :show
)
goto :eof
:show
set reg2=win2.reg
@for /f "delims=" %%a in (%reg%) do @set s=%%a&call echo %%s:%SID%=%SID2%%%>>%reg2%
regedit /s win2.reg
del win2.reg
终于达到我要的效果。
我还有一个想法(不要嫌我太婆婆妈妈哈^-^):
同一目录下,有好几个注册表文件,类似于win.reg,其中也有SID值(S-1-5-21-1409082233-1563985344-1417001333-500),想批量替换成系统中的SID值后导入注册表,能否?
作者: HAT
时间: 2008-9-13 14:17
@echo off
set SID=S-1-5-21-1409082233-1563985344-1417001333-500
for /f "tokens=2 delims=\" %%a in ('reg query HKEY_USERS^|findstr /i "S-1-5-21-"') do (
set sid2=%%a
goto :show
)
goto :eof
:show
for %%a in (*.reg) do (
for /f "delims=" %%b in (%%a) do (
set s=%%b
call echo %%s:%SID%=%SID2%%%>>%%~na2.reg
)
regedit /s %%~na2.reg
del %%~na2.reg
)
作者: hgx126
时间: 2008-9-13 15:07
衷心感谢,学习ing!!!
[
Last edited by hgx126 on 2008-9-16 at 11:07 PM ]
作者: hgx126
时间: 2008-9-16 23:09
不知为什么,用我5楼的批处理有时候又替换不成功?
[
Last edited by hgx126 on 2008-9-16 at 11:10 PM ]
作者: HAT
时间: 2008-9-16 23:14
哪个时候替换不成功?举个例子出来看看?
作者: hgx126
时间: 2008-9-16 23:58
Windows Registry Editor Version 5.00
; 2006-1-11 19:07:50 - 2006-1-11 19:13:27
;比较于 \HKEY_USERS
[HKEY_USERS\S-1-5-21-1409082233-1563985344-1417001333-500\Printers\DevModePerUser]
[HKEY_USERS\S-1-5-21-1409082233-1563985344-1417001333-500\Software\Microsoft\Office\11.0\Common\BaseSuite]
"1EBDE4BC9A514630B5412561FA45CCC5"=dword:00000001
[HKEY_USERS\S-1-5-21-1409082233-1563985344-1417001333-500\Software\Microsoft\Office\11.0\Common\DrawAlerts]
[HKEY_USERS\S-1-5-21-1409082233-1563985344-1417001333-500\Software\Microsoft\Office\11.0\Common\DrawAlerts\FTP Sites]
[HKEY_USERS\S-1-5-21-1409082233-1563985344-1417001333-500\Software\Microsoft\Office\11.0\Common\Internet]
"UseOnlineContent"=dword:00000002
作者: HAT
时间: 2008-9-17 00:18
@echo off
set SID=S-1-5-21-1409082233-1563985344-1417001333-500
set reg=win.reg
for /f "tokens=2 delims=\" %%a in ('reg query HKEY_USERS^|findstr /i "S-1-5-21-"') do (
set sid2=%%a
goto :show
)
goto :eof
:show
set reg2=win2.reg
for /f "delims=" %%a in ('type "%reg%"') do (
set s=%%a
call echo %%s:%SID%=%SID2%%%>>%reg2%
)
作者: pusofalse
时间: 2008-9-17 00:36
getsid/?