找回密码
 加入
搜索
查看: 10409|回复: 16

[AU3基础] [已解决]如何删除注册表文件重复的项???

 火.. [复制链接]
发表于 2011-3-19 23:41:31 | 显示全部楼层 |阅读模式
本帖最后由 pchome2000 于 2011-3-20 17:45 编辑

如何删除注册表文件重复的项???

[HKLM\SYStem\ControlSet001\Services\msisadrv]
"ErrorControl"=dword:00000001
"Group"="SCSI Miniport"
"Start"=dword:00000000
"Type"=dword:00000001
"ImagePath"=hex(2):73,00,79,00,73,00,74,00,65,00,6D,00,33,00,32,00,5C,00,64,00,72,00,69,00,76,00,65,00,72,00,73,00,5C,00,6D,00,73,00,69,00,73,00,61,00,64,00,72,00,76,00,2E,00,73,00,79,00,73,00
[HKLM\SYStem\ControlSet001\Services\msisadrv]
"ErrorControl"=dword:00000001
"Group"="SCSI Miniport"
"Start"=dword:00000000
"Type"=dword:00000001
"ImagePath"=hex(2):73,00,79,00,73,00,74,00,65,00,6D,00,33,00,32,00,5C,00,64,00,72,00,69,00,76,00,65,00,72,00,73,00,5C,00,6D,00,73,00,69,00,73,00,61,00,64,00,72,00,76,00,2E,00,73,00,79,00,73,00
[HKLM\SYStem\ControlSet001\Services\sis]
"ErrorControl"=dword:00000001
"Group"="SCSI Miniport"
"Start"=dword:00000000
"Type"=dword:00000001
"ImagePath"=hex(2):73,00,79,00,73,00,74,00,65,00,6D,00,33,00,32,00,5C,00,64,00,72,00,69,00,76,00,65,00,72,00,73,00,5C,00,6D,00,73,00,69,00,73,00,61,00,64,00,72,00,76,00,2E

[HKLM\SYStem\ControlSet001\Services\pci]
"ErrorControl"=dword:00000001
"Group"="SCSI Miniport"
"Start"=dword:00000000
"Type"=dword:00000001
"ImagePath"=hex(2):73,00,79,00,73,00,74,00,65,00,6D,00,33,00,32,00,5C,00,64,00,72,00,69,00,76,00,65,00,72,00,73,00,5C,00,70,00,63,00,69,00,2E,00,73,00,79,00,73,00
发表于 2011-3-20 01:22:25 | 显示全部楼层
没见过hSYS\ControlSet00项
 楼主| 发表于 2011-3-20 09:53:32 | 显示全部楼层
没见过hSYS\ControlSet00项
netegg 发表于 2011-3-20 01:22



    这个不重要啊,是如何删除重复的值,请各位高手帮帮忙。
发表于 2011-3-20 11:52:40 | 显示全部楼层
本帖最后由 netegg 于 2011-3-20 11:58 编辑

回复 3# pchome2000

你不说明白,怎么解释,如果是controlset001/002/current的话,只修改001的就行了,002是个备份,如果重启成功,会自动更新过去
current就是001在当前运行时的一个镜像

你把内容改了?但是,在一个子项下好像没法建立同名子项吧?
 楼主| 发表于 2011-3-20 13:20:28 | 显示全部楼层
回复 4# netegg


    谢谢你的回答,我是想删除重复的项,即要改成:

[HKLM\SYStem\ControlSet001\Services\msisadrv]
"ErrorControl"=dword:00000001
"Group"="SCSI Miniport"
"Start"=dword:00000000
"Type"=dword:00000001
"ImagePath"=hex(2):73,00,79,00,73,00,74,00,65,00,6D,00,33,00,32,00,5C,00,64,00,72,00,69,00,76,00,65,00,72,00,73,00,5C,00,6D,00,73,00,69,00,73,00,61,00,64,00,72,00,76,00,2E,00,73,00,79,00,73,00

[HKLM\SYStem\ControlSet001\Services\sis]
"ErrorControl"=dword:00000001
"Group"="SCSI Miniport"
"Start"=dword:00000000
"Type"=dword:00000001
"ImagePath"=hex(2):73,00,79,00,73,00,74,00,65,00,6D,00,33,00,32,00,5C,00,64,00,72,00,69,00,76,00,65,00,72,00,73,00,5C,00,6D,00,73,00,69,00,73,00,61,00,64,00,72,00,76,00,2E

[HKLM\SYStem\ControlSet001\Services\pci]
"ErrorControl"=dword:00000001
"Group"="SCSI Miniport"
"Start"=dword:00000000
"Type"=dword:00000001
"ImagePath"=hex(2):73,00,79,00,73,00,74,00,65,00,6D,00,33,00,32,00,5C,00,64,00,72,00,69,00,76,00,65,00,72,00,73,00,5C,00,70,00,63,00,69,00,2E,00,73,00,79,00,73,00
发表于 2011-3-20 14:35:00 | 显示全部楼层
本帖最后由 netegg 于 2011-3-20 14:39 编辑

这三个不是一个东西呀,怎么叫重复的?
那三段分别对应着三个不同的服务

如果瞎猜测一下,你是不是想删除文本文件的相同行?
 楼主| 发表于 2011-3-20 14:40:15 | 显示全部楼层
本帖最后由 pchome2000 于 2011-3-20 14:44 编辑

回复 6# netegg

即将以下内容删除重复的项:
[HKLM\SYStem\ControlSet001\Services\msisadrv]
"ErrorControl"=dword:00000001
"Group"="SCSI Miniport"
"Start"=dword:00000000
"Type"=dword:00000001
"ImagePath"=hex(2):73,00,79,00,73,00,74,00,65,00,6D,00,33,00,32,00,5C,00,64,00,72,00,69,00,76,00,65,00,72,00,73,00,5C,00,6D,00,73,00,69,00,73,00,61,00,64,00,72,00,76,00,2E,00,73,00,79,00,73,00
[HKLM\SYStem\ControlSet001\Services\msisadrv]
"ErrorControl"=dword:00000001
"Group"="SCSI Miniport"
"Start"=dword:00000000
"Type"=dword:00000001
"ImagePath"=hex(2):73,00,79,00,73,00,74,00,65,00,6D,00,33,00,32,00,5C,00,64,00,72,00,69,00,76,00,65,00,72,00,73,00,5C,00,6D,00,73,00,69,00,73,00,61,00,64,00,72,00,76,00,2E,00,73,00,79,00,73,00
[HKLM\SYStem\ControlSet001\Services\sis]
"ErrorControl"=dword:00000001
"Group"="SCSI Miniport"
"Start"=dword:00000000
"Type"=dword:00000001
"ImagePath"=hex(2):73,00,79,00,73,00,74,00,65,00,6D,00,33,00,32,00,5C,00,64,00,72,00,69,00,76,00,65,00,72,00,73,00,5C,00,6D,00,73,00,69,00,73,00,61,00,64,00,72,00,76,00,2E

[HKLM\SYStem\ControlSet001\Services\pci]
"ErrorControl"=dword:00000001
"Group"="SCSI Miniport"
"Start"=dword:00000000
"Type"=dword:00000001
"ImagePath"=hex(2):73,00,79,00,73,00,74,00,65,00,6D,00,33,00,32,00,5C,00,64,00,72,00,69,00,76,00,65,00,72,00,73,00,5C,00,70,00,63,00,69,00,2E,00,73,00,79,00,73,00

删除重复项后变成:
[HKLM\SYStem\ControlSet001\Services\msisadrv]
"ErrorControl"=dword:00000001
"Group"="SCSI Miniport"
"Start"=dword:00000000
"Type"=dword:00000001
"ImagePath"=hex(2):73,00,79,00,73,00,74,00,65,00,6D,00,33,00,32,00,5C,00,64,00,72,00,69,00,76,00,65,00,72,00,73,00,5C,00,6D,00,73,00,69,00,73,00,61,00,64,00,72,00,76,00,2E,00,73,00,79,00,73,00

[HKLM\SYStem\ControlSet001\Services\sis]
"ErrorControl"=dword:00000001
"Group"="SCSI Miniport"
"Start"=dword:00000000
"Type"=dword:00000001
"ImagePath"=hex(2):73,00,79,00,73,00,74,00,65,00,6D,00,33,00,32,00,5C,00,64,00,72,00,69,00,76,00,65,00,72,00,73,00,5C,00,6D,00,73,00,69,00,73,00,61,00,64,00,72,00,76,00,2E

[HKLM\SYStem\ControlSet001\Services\pci]
"ErrorControl"=dword:00000001
"Group"="SCSI Miniport"
"Start"=dword:00000000
"Type"=dword:00000001
"ImagePath"=hex(2):73,00,79,00,73,00,74,00,65,00,6D,00,33,00,32,00,5C,00,64,00,72,00,69,00,76,00,65,00,72,00,73,00,5C,00,70,00,63,00,69,00,2E,00,73,00,79,00,73,00
发表于 2011-3-20 14:51:31 | 显示全部楼层
本帖最后由 netegg 于 2011-3-20 15:00 编辑

#include<file.au3>
#include<array.au3>
local $aA, $aB
_filereadtoarray($file,$aA)
arraydelete($aA, 0)
$aB = _arrayunique($aA)
fileopen($file, 1)
_filewritefromarray($file, $aB)
fileclose($file)
大概删多了
发表于 2011-3-20 15:02:54 | 显示全部楼层
那就换种方法
local $aA = inireadsection($file)
这样去转换下也行
 楼主| 发表于 2011-3-20 15:03:49 | 显示全部楼层
回复 8# netegg

我是想保留这些子项,
"ErrorControl"=dword:00000001
"Group"="SCSI Miniport"
"Start"=dword:00000000
"Type"=dword:00000001

_arrayunique删除不重复的项,会把子项一并删除???
 楼主| 发表于 2011-3-20 15:05:21 | 显示全部楼层
回复 9# netegg


    不太明白,可否详细说明一下???
发表于 2011-3-20 15:41:45 | 显示全部楼层
利用ini配置文件的相关操作函数如IniRead、IniWrite来处理,因为这些注册信息的数据结构符合ini格式标准,
标准 INI 文件结构如下:
[字段名]
关键字=值
所以直接用IniRead读取出来,然后用IniWrite写入到一个新文件中,按照函数的特性,在那个新的文件中,如果已存在字段名,则数据将添加到此字段名中,如果已存在关键字,则会更新关键字的值,而不是另建一个同名的关键字
发表于 2011-3-20 15:46:52 | 显示全部楼层
#include<array.au3>
Local $file='1.txt', $file1='11.txt'
local $aA  = IniReadSectionNames($file), $aB
_arraydelete($aA, 0)
$aB = _arrayunique($aA)
_arraydelete($aB, 0)
for $i =  0 to ubound($aB)-1
  $key = inireadsection($file, $aB[$i])
  For $j = 1 To $key[0][0]
          IniWrite($file1, $aB[$i], $key[$j][1], $key[$j][0])
  Next
Next
FileMove($file1, $file, 1)
FileDelete($file1)

评分

参与人数 1金钱 +10 贡献 +3 收起 理由
lixiaolong + 10 + 3 学习了

查看全部评分

发表于 2011-3-20 15:47:44 | 显示全部楼层
$file='1.txt'这是源文件
$file1='11.txt'这是个过渡文件,最后删掉
发表于 2011-3-20 16:49:18 | 显示全部楼层
我也来一个.

_RemoveDuplicateRegSection(@DesktopDir & '\新建文本文档.reg')

Func _RemoveDuplicateRegSection($RegFile)
        Local $SectionNames = IniReadSectionNames($RegFile)
        Local $NewRegFile = @TempDir & '\tmp.reg'
        For $i = 1 To UBound($SectionNames) - 1
                $Section = IniReadSection($RegFile, $SectionNames[$i])
                For $s = 1 To $Section[0][0]
                        IniWrite($NewRegFile, $SectionNames[$i], $Section[$s][0], $Section[$s][1])
                Next
        Next
        FileDelete($RegFile)
        FileMove($NewRegFile, $RegFile)
EndFunc   ;==>_RemoveDuplicateRegSection
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-11-16 23:35 , Processed in 0.085874 second(s), 27 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表