|
shgengen
新手上路

积分 8
发帖 2
注册 2006-4-4
状态 离线
|
『楼 主』:
大虾级问题,关键词:批处理、注册表。期待斑竹!
使用 LLM 解释/回答一下
各位大虾,小弟弟第一次来,问一个对我来说很深的问题。
实现效果:
每次重新启动,系统便会调用备份的注册表。在系统启动后所作的一切注册表修改,都会在系统重新启动后调用备份的注册表。
要求在win98、win2K、winxp、win2k3都能实现
本人想的思路是:
利用批处理
删除整个注册表
调用备份注册表
但是本人能力有限,无法实现,期待高手的出现。
Dear all, this is my first time here, and I have a very deep question.
Implementation effect:
Every time the system restarts, it will call the backed-up registry. All registry modifications made after the system starts will be replaced by the backed-up registry after the system restarts.
It is required to be implementable in win98, win2K, winxp, win2k3.
My own idea is:
Use batch processing
Delete the entire registry
Call the backed-up registry
But my ability is limited, and I can't implement it. Looking forward to the appearance of experts.
|
|
2006-4-4 16:06 |
|
|
bagpipe
银牌会员
     DOS联盟捡破烂的
积分 1144
发帖 425
注册 2005-10-20 来自 北京
状态 离线
|
『第 2 楼』:
使用 LLM 解释/回答一下
OH ,MY GOD.....不知道是楼主发烧还是我发烧.........删除注册表?????在说一句“OH ,MY GOD!"
OH ,MY GOD.....I don't know if the original poster has a fever or I do.........Delete the registry?????Say another "OH ,MY GOD!"
|
|
2006-4-4 17:43 |
|
|
3742668
荣誉版主
      
积分 2013
发帖 718
注册 2006-2-18
状态 离线
|
『第 3 楼』:
使用 LLM 解释/回答一下
为什么要备份和恢复整个注册表呢?如果是我会有选择地备份。。
不过按照你的思路可以提供方法给你:
备份注册表的命令: regedit /e c:\bak.reg
导入注册表的命令: regedit /s c:\bak.reg
虽然regedit命令在98和XP下都能运行,但是对于XP来说,涉及到权限等等情况,也许不一定能恢复成功(这只是我的意见。)
如果是98的话建议你只是备份System.dat和User.dat就行了,然后等想恢复的时候再恢复。
毕竟每次启动的时候恢复注册表是要等上一段时间的。
ps:个人认为这个问题还算不上什么大虾级的问题吧。。
Why back up and restore the entire registry? If it were me, I would selectively back up...
But according to your train of thought, I can provide you with methods:
Command to back up the registry: regedit /e c:\bak.reg
Command to import the registry: regedit /s c:\bak.reg
Although the regedit command can run under 98 and XP, for XP, involving permissions and other situations, maybe it won't necessarily restore successfully (this is just my opinion.)
If it's 98, it's suggested that you just back up System.dat and User.dat, and then restore when you want to.
After all, restoring the registry every time you start up takes some time.
ps: Personally, I think this problem isn't even what can be considered a big shot-level problem.
|
|
2006-4-4 17:54 |
|
|
Climbing
铂金会员
       网络独行侠
积分 6962
发帖 2753
注册 2003-4-16 来自 河北保定
状态 离线
|
『第 4 楼』:
使用 LLM 解释/回答一下
xp也能通过直接备份注册表文件的方式来备份注册表,不过前提是xp没有在运行状态。而恢复备份的注册表,也是同样的要求。
个人认为,这确实不是一个大虾级的问题。
XP can also back up the registry by directly backing up the registry file, but the premise is that XP is not in the running state. And the same requirement applies when restoring the backed-up registry. Personally, I think this is really not a problem for an expert-level person.
|

偶只喜欢回答那些标题和描述都很清晰的帖子!
如想解决问题,请认真学习“这个帖子”和“这个帖子”并努力遵守,如果可能,请告诉更多的人!
|
|
2006-4-4 18:08 |
|
|
lpclimber
初级用户
 
积分 168
发帖 85
注册 2005-8-26
状态 离线
|
『第 5 楼』:
使用 LLM 解释/回答一下
Originally posted by 3742668 at 2006-4-4 17:54:
备份注册表的命令: regedit /e c:\bak.reg
导入注册表的命令: regedit /s c:\bak.reg
我也看到过别人提到一个 regedit -m打开两个regedit.exe
请问 regedit 的这些参数是如何获得的?
我到微软官方网站搜索,找了很久就是找不到全面介绍这些参数的~~
Originally posted by 3742668 at 2006-4-4 17:54:
Command to back up the registry: regedit /e c:\bak.reg
Command to import the registry: regedit /s c:\bak.reg
I also saw others mention that a regedit -m opens two regedit.exe
May I ask how these parameters of regedit are obtained?
I searched on the Microsoft official website for a long time but couldn't find a comprehensive introduction to these parameters~~
|
|
2006-4-5 00:06 |
|
|
3742668
荣誉版主
      
积分 2013
发帖 718
注册 2006-2-18
状态 离线
|
『第 6 楼』:
使用 LLM 解释/回答一下
DOS下regedit /?
我以前用98的时候专门看过的,所以还有点印象,不过在XP的命令行中运行regedit /?看不出来了,但是regedit /s和regedit /e还是能执行。
DOS下regedit /?
I used to specifically look at it when I was using 98, so I still have some impression. But in the command line of XP, running regedit /? can't be seen, but regedit /s and regedit /e can still be executed.
|
|
2006-4-5 00:23 |
|
|
shgengen
新手上路

积分 8
发帖 2
注册 2006-4-4
状态 离线
|
『第 7 楼』:
使用 LLM 解释/回答一下
也许本人没有叙述清楚
本人的意思就是
在装好系统和应用软件后,系统交给用户使用,使用户不能通过安装应用程序往注册表中添加信息。即使安装了需要往注册表中添加信息中的软件,在重新启动后,也会因为注册表被复原而无法正常运行。。。(绿色软件除外)
按照3楼的意见,是 不是可以在系统运行前,在组策略中执行批处理命令
regedit /s e:\bak.reg
注释:bak.reg为系统安装后导出的注册表。这样,每次重新启动系统,使用的就是bak.reg了。
但是我在考虑这样的问题,假如用户在注册表中添加了新的信息后,再导入bak.reg,是不是会引起系统错误,(新添加的信息是否被清除)
Maybe I didn't describe it clearly.
What I mean is that after installing the system and application software, the system is handed over to the user for use, so that the user cannot add information to the registry by installing application programs. Even if the software that needs to add information to the registry is installed, after restarting, it will not run normally because the registry is restored... (except for green software)
According to the opinion of floor 3, can we execute a batch command in the group policy before the system runs:
regedit /s e:\bak.reg
Note: bak.reg is the registry exported after the system is installed. In this way, every time the system is restarted, the one used is bak.reg.
But I'm thinking about such a problem. If the user adds new information to the registry and then imports bak.reg, will it cause system errors, (whether the newly added information is cleared)
|
|
2006-4-5 08:37 |
|
|
3742668
荣誉版主
      
积分 2013
发帖 718
注册 2006-2-18
状态 离线
|
『第 8 楼』:
使用 LLM 解释/回答一下
首先,如果你的注册表中更改了设置时,导入bak.reg会修改为bak.reg中的值,但是如果键是添加上去的,导入bak.reg的时候并不会删除已经建立的值(这也是为什么我说在98系统下最好是备份和恢复system.dat和user.dat的原因)。在98下面我们可以在autoexec.bat或win.bat等中恢复system.dat和user.dat来实现真正地恢复注册表的目的,但是在XP下此方法并不实用。而且随着软件的变化而注册表不相映地配置得当的话,可能会导致软件无法正常使用等等莫名其妙的情况。所以基本上是不要干这种吃力不讨好的事情,至于实现你想实现的目的,在XP环境中你只需要建立一个权限比较低的用户就可以了,比如users组的就可以。如果你硬是要自己来修改注册表的话也不是不行,你可以每次先导处注册表,然后利用批处理把每个以"["开头的行提取出来,再在提出的文件的第二个有效字符前插入一个减号"-",比如原内容为:
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run]
只需要改为
[-HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run]
就行了,然后再把更改过的reg文件导入,这就实现了删除所有子键(当然,你也可以直接把各个根键下的子键名记下来,然后在批处理中直接删除这些子键即可)。
删除键后再把bak.reg导入即可。
还是不推荐用这种最笨最没有效率且最危险的方法来维护安全。
First of all, if you change settings in the registry, importing bak.reg will modify it to the values in bak.reg. But if a key is added, importing bak.reg will not delete the already established values (this is why I said it's best to back up and restore system.dat and user.dat under Windows 98). Under Windows 98, we can restore system.dat and user.dat in autoexec.bat or win.bat, etc., to achieve the purpose of truly restoring the registry. But this method is not practical under XP. Moreover, if the software changes and the registry is not properly configured accordingly, it may lead to inexplicable situations such as the software not working properly. So basically, don't do this thankless thing. As for achieving the purpose you want, in the XP environment, you only need to create a user with a relatively low privilege, such as in the users group. If you really want to modify the registry yourself, it's not impossible. You can first export the registry each time, then use a batch script to extract each line starting with "
Just change it to
Then import the modified reg file, which will delete all subkeys (of course, you can also directly record the names of the subkeys under each root key and then directly delete these subkeys in the batch script).
After deleting the key, import bak.reg.
It is still not recommended to use this most cumbersome, least efficient, and most dangerous method to maintain security.
|
|
2006-4-5 10:41 |
|
|
lpclimber
初级用户
 
积分 168
发帖 85
注册 2005-8-26
状态 离线
|
|
2006-4-5 13:12 |
|
|
Climbing
铂金会员
       网络独行侠
积分 6962
发帖 2753
注册 2003-4-16 来自 河北保定
状态 离线
|
『第 10 楼』:
使用 LLM 解释/回答一下
装个硬盘保护卡倒是相当的简单。也能满足楼主的需要。
Installing a hard drive protection card is quite simple. It can also meet the owner's needs.
|

偶只喜欢回答那些标题和描述都很清晰的帖子!
如想解决问题,请认真学习“这个帖子”和“这个帖子”并努力遵守,如果可能,请告诉更多的人!
|
|
2006-4-5 18:33 |
|
|
electronixtar
铂金会员
      
积分 7493
发帖 2672
注册 2005-9-2
状态 离线
|
『第 11 楼』:
使用 LLM 解释/回答一下
regedit /c 好像可以用.reg重建注册表
regedit /c seems to be able to use .reg to rebuild the registry
|
|
2006-5-11 13:26 |
|
|
willsort
元老会员
         Batchinger
积分 4432
发帖 1512
注册 2002-10-18
状态 离线
|
『第 12 楼』:
使用 LLM 解释/回答一下
Re shgengen:
根据你在7楼需求描述,感觉与网吧系统的维护有些相似性。这种情况下,通常是不会采用恢复注册表的方式来限制非绿色应用程序的使用的,这种方法除了复杂度大、兼容性差、危险性高等缺点外,还具有易产生冗余文件的缺陷。因此,此类需求通常采用以下方案。
一、Climbing兄在10楼提到的硬盘保护卡或者硬盘还原类软件,对系统盘进行写保护,使之每次启动后可以自动恢复初始状态,绿色软件可以安装在非系统盘而不受影响。
二、使用类似一键还原的自启动型镜像还原软件,预先对系统盘进行备份,在系统盘发生较大变化后进行恢复。因为恢复所需时间较方案一长很多,所以恢复周期也需要适当加长,比如每天的第一次启动时恢复,而非每次启动时恢复。
另外,Win9x下有现成的恢复注册表工具,scanreg.exe/scanregw.exe,将 scanreg /restore 写入到 autoexec.bat 中,或者将 scanregw /restore 写入到注册表的 run 启动项下,可以使其启动时自动恢复注册表。
Last edited by willsort on 2006-5-11 at 19:36 ]
Re shgengen:
According to the requirement description you provided on floor 7, it feels somewhat similar to the maintenance of an internet café system. In such cases, restoring the registry is usually not the method adopted to restrict the use of non-green applications. In addition to the disadvantages of high complexity, poor compatibility, and high risk, this method also has the defect of easily generating redundant files. Therefore, the following solutions are usually adopted for such requirements.
1. The hard disk protection card or hard disk restoration software mentioned by Brother Climbing on floor 10 can write-protect the system disk, so that it can automatically restore to the initial state after each boot, and green software can be installed on the non-system disk without being affected.
2. Use a self-starting image restoration software similar to One-click Restore to back up the system disk in advance, and restore it after the system disk changes significantly. Because the restoration takes much longer than solution 1, the restoration cycle also needs to be appropriately extended, for example, restoring at the first boot every day instead of at every boot.
In addition, there are ready-made registry restoration tools under Win9x, scanreg.exe/scanregw.exe. Writing scanreg /restore into autoexec.bat or writing scanregw /restore into the run startup item in the registry can make it automatically restore the registry at startup.
Last edited by willsort on 2006-5-11 at 19:36 ]
|

※ Batchinger 致 Bat Fans:请访问 批处理编程的异类 ,欢迎交流与共享批处理编程心得! |
|
2006-5-11 19:00 |
|
|
asbai
高级用户
   
积分 653
发帖 252
注册 2006-4-16
状态 离线
|
『第 13 楼』:
使用 LLM 解释/回答一下
用regedit的导入、导出功能涉及到数据表示的转换(二进制数据<->纯文本数据)。在典型配置中,每次启动对整个注册表做这样的转换,耗时太过巨大了。还不如用磁盘映像恢复合算,除非你磁盘IO巨慢但CPU巨快(一个是计算密集型一个是IO密集型)。
如果仅仅要完整恢复注册表,用文件覆盖是最简单高效的做法,但是NT Kernel的OS要在系统启动(注册表文件被装载并锁定)前执行覆盖比较麻烦,好像有两种办法
【方法一】
1. 开机自检
2. 从MBR装入boot manager,发现是单数次启动
3. 装入一个独立的DOS系统
4. [可选]装入NTFS文件系统驱动
5. 用备份的注册表文件覆盖系统文件
6. 重启机器,再次装入boot manager,发现是偶数次启动
7. 装入NT/2k/XP/2k3
显然,这个方案必须有个支持某些非易失标志位判断的boot manager。
【方法二】
1. 开机自检
2. 从MBR启动独立的DOS系统
3. [可选]装入NTFS文件系统驱动
4. 用备份的注册表文件覆盖系统文件
5. 加载GRUB4DOS,并用它加载NT系列OS
就是不知道GRUB4DOS能不能直接在DOS下加载NT Kernel。就算可以,似乎也要吃掉最少1M左右的内存。
The import and export functions of regedit involve conversion of data representation (binary data <-> plain text data). In a typical configuration, the time-consuming conversion for the entire registry each time it starts is too great. It's not as cost-effective as restoring with disk images, unless your disk IO is extremely slow but CPU is extremely fast (one is compute - intensive and the other is IO - intensive).
If you just want to fully restore the registry, overwriting the file is the simplest and most efficient way. But for NT Kernel OS, it is more troublesome to perform the overwrite before the system starts (the registry file is loaded and locked). It seems there are two methods.
**Method 1**
1. Power - on self - test
2. Load boot manager from MBR, find it's the odd - numbered start
3. Load an independent DOS system
4. Load NTFS file system driver
5. Overwrite the system file with the backed - up registry file
6. Restart the machine, load boot manager again, find it's the even - numbered start
7. Load NT/2k/XP/2k3
Obviously, this scheme must have a boot manager that supports judging some non - volatile flag bits.
**Method 2**
1. Power - on self - test
2. Boot an independent DOS system from MBR
3. Load NTFS file system driver
4. Overwrite the system file with the backed - up registry file
5. Load GRUB4DOS and use it to load NT series OS
Just don't know if GRUB4DOS can directly load NT Kernel under DOS. Even if it can, it seems that at least about 1M of memory will be consumed.
|
|
2006-5-11 23:07 |
|