本帖最后由 newuser 于 2010-9-8 09:26 编辑
请看下面2个INI文件:FixedList.ini内容:
[已经安装的补丁]
KB2079403=1
KB2115168=1
KB2160329=1
KB2183461=1
KB2229593=1
KB2264107=1
KB2286198=1
KB923561=1
KB924667-v2=1
KB925398_WMP64=1
KB925902-v2=1
KB927891=1
KB929123=1
KB930178=1
KB932168=1
KB932716-v2=1
KB933729=1
KB935839=1
KB935840=1
KB936021=1
KB936357-v2=1
KB936782=1
KB938127=1
KB938464-v2=1
KB941569=1
KB941644=1
KB942288-v4=1
KB943055=1
KB943460=1
KB943485=1
KB944338-v2=1
KB944653=1
KB945553=1
KB946026=1
KB948496=1
KB950224-v3=1
KB950582=1
KB950762=1
KB950974=1
KB951066=1
KB951698=1
KB951748=1
KB952004=1
KB952069=1
KB952954=1
KB953155=1
KB953298=1
KB954155=1
KB954211=1
KB954708=1
KB955069=1
KB955704=1
KB955759=1
KB956391=1
KB956572=1
KB956802=1
KB956803=1
KB956844=1
KB957097=1
KB958469=1
KB958644=1
KB958687=1
KB958690=1
KB958752=1
KB958869=1
KB959426=1
KB960225=1
KB960714=1
KB960715=1
KB960803=1
KB960859=1
KB961371=1
KB961371-v2=1
KB961373=1
KB961501=1
KB963027=1
KB967715=1
KB967723=1
KB968389=1
KB968537=1
KB968816=1
KB969059=1
KB969897=1
KB969898=1
KB969947=1
KB970238=1
KB970483=1
KB971032=1
KB971314=1
KB971468=1
KB971486=1
KB971513=1
KB971557=1
KB971633=1
KB971657=1
KB971737=1
KB971961=1
KB972260=1
KB972270=1
KB973354=1
KB973507=1
KB973525=1
KB973540=1
KB973815=1
KB973869=1
KB973904=1
KB974112=1
KB974318=1
KB974392=1
KB974455=1
KB974571=1
KB975025=1
KB975254=1
KB975467=1
KB975560=1
KB975562=1
KB975713=1
KB976323=1
KB976325=1
KB977165=1
KB977290=1
KB977816=1
KB977914=1
KB978037=1
KB978207=1
KB978251=1
KB978262=1
KB978338=1
KB978542=1
KB978601=1
KB978695=1
KB978706=1
KB979309=1
KB979482=1
KB979559=1
KB979683=1
KB979907=1
KB980182=1
KB980195=1
KB980218=1
KB980232=1
KB980436=1
KB981350=1
KB982214=1
KB982316=1
KB982381=1
KB982666=1
Q147222=1
ServicePackUninstall=1
WebList.ini:
[补丁服务器]
KB983582=1
KB983583=1
KB982214=1
KB2183461=1
KB2115168=1
KB982316=1
KB2079403=1
KB980436=1
KB2160329=1
KB2286198=1
KB2229593=1
KB979907=1
KB982666=1
KB980218=1
KB982381=1
KB980195=1
KB975562=1
KB978695=1
KB979482=1
KB979559=1
KB978542=1
KB978338=1
KB977816=1
KB976323=1
KB981350=1
KB981349=1
KB979683=1
KB980232=1
KB978601=1
KB979309=1
KB980182=1
KB977165=1
KB977290=1
KB977914=1
KB975560=1
KB971468=1
KB978037=1
KB978262=1
KB975713=1
KB978251=1
KB978706=1
KB978207=1
KB972270=1
KB973904=1
KB974318=1
KB974392=1
KB969947=1
KB958869=1
KB975467=1
KB971486=1
KB969059=1
KB974571=1
KB973525=1
KB974455=1
KB975254=1
KB974112=1
KB969878=1
KB967723=1
KB956844=1
KB956744=1
KB958469=1
KB960859=1
KB971657=1
KB969883=1
KB971557=1
KB973540=1
KB973507=1
KB973869=1
KB973815=1
KB972260=1
KB973346=1
KB961371=1
KB971633=1
KB970238=1
KB968537=1
KB961501=1
KB970483=1
KB969897=1
KB970437=1
KB959426=1
KB963027=1
KB960803=1
KB952004=1
KB961373=1
KB923561=1
KB960225=1
KB958690=1
KB958687=1
KB960714=1
KB955069=1
KB957097=1
KB958644=1
KB938464=1
KB950974=1
KB952954=1
KB943485=1
KB941644=1
如何比较他们的不同,并将不同内容写到一个INI文件内,以下是我的代码,但怎么比都是相同的呢?Dim $NewPatchsList=@ScriptDir&"\NewList.ini";下面2个文件对比将不同部分写入
$file = FileOpen(@ScriptDir&"\WebList.ini", 0);来自WEB
$file1=FileOpen(@ScriptDir&"\FixedList.ini",0);来自计算机原有
$file1contents=FileRead($file1)
;MsgBox(0,"",$file1contents)
; 检查打开的文件是否可读
If $file = -1 Then
MsgBox(0, "错误", "不能打开文件.")
Exit
EndIf
; 每次读取一行文本,直到文件结束.
While 1
$line = FileReadLine($file)
If @error = -1 Then ExitLoop
StringInStr($file1contents,$line)
If @error = 1 Then
$New=StringSplit($line,"=",1)
IniWrite($NewPatchsList,"未安装补丁",$New[1],"1")
ElseIf @error = 0 Then
msgbox(64, "提示", " 2个文件相同")
Exit
EndIf
Wend
FileClose($file)
FileClose($file1)
|