找回密码
 加入
搜索
查看: 3897|回复: 6

[系统综合] [已解决]如何将计算机已经打的补丁写入到一个文件内?

  [复制链接]
发表于 2010-8-9 15:28:18 | 显示全部楼层 |阅读模式
本帖最后由 newuser 于 2010-8-9 16:57 编辑

以下2段代码怎么都只写了一个补丁文件名到文件内?
#cs
While 1
        Dim $FixedPatchsRegPath="HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\HotFix"
        Dim $FixedPatchsListPath=@TempDir & "\FixedPatchsList.ini"
        Dim $i
        $i +=1
        $Var=RegEnumKey($FixedPatchsRegPath,$i)
        
        If @error <>0  Then ExitLoop
        FileOpen($FixedPatchsListPath,8) ;8表示如果指定打开目录不存在那么强制建立它!
        FileWriteLine($FixedPatchsListPath,$Var & @CRLF);将枚举出的值逐行写入到指定的ini文件中
WEnd
        FileClose($FixedPatchsListPath)
#ce

For $i= 1 to 1000
        Dim $FixedPatchsListPath=@ScriptDir & "\FixedPatchsList.ini"
    $var = RegEnumKey("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\HotFix", $i)
        ;MsgBox(0,'',$var)
    If @error <> 0 then ExitLoop
    FileOpen($FixedPatchsListPath)
        FileWriteLine($FixedPatchsListPath,$var & @CRLF)
Next
FileClose($FixedPatchsListPath)

评分

参与人数 1金钱 +10 收起 理由
afan + 10 感谢主动将修改帖子分类为[已解决],请继续 ...

查看全部评分

发表于 2010-8-9 15:54:23 | 显示全部楼层
代码没什么问题吧
测试了下貌似正常
发表于 2010-8-9 16:04:43 | 显示全部楼层
Dim $FileOpen = FileOpen(@ScriptDir & "\FixedPatchsList.ini", 9), $i
Dim $FixedPatchsRegPath = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\HotFix"
While 1
        $i += 1
        $var = RegEnumKey($FixedPatchsRegPath, $i)
        If @error Then ExitLoop
        FileWriteLine($FileOpen, $var)
WEnd
#cs
For $i = 1 To 1000
        $var = RegEnumKey($FixedPatchsRegPath, $i)
        If @error Then ExitLoop
        FileWriteLine($FileOpen, $var)
Next
#ce
FileClose($FileOpen)
发表于 2010-8-9 16:08:46 | 显示全部楼层
楼上动作好快。
Dim $FixedPatchsRegPath="HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\HotFix"
Dim $FixedPatchsListPath="FixedPatchsList.ini"
FileOpen($FixedPatchsListPath,8)
Dim $i = 0
While 1

        $i = $i + 1
        $Var=RegEnumKey($FixedPatchsRegPath,$i)
        If @error <> 0  Then ExitLoop
        FileWriteLine($FixedPatchsListPath,$Var & @CRLF);将枚举出的值逐行写入到指定的ini文件中
WEnd
FileClose($FixedPatchsListPath)
 楼主| 发表于 2010-8-9 16:56:24 | 显示全部楼层
回复 3# afan
谢谢,解决了!应该在while循环之前打开ini文件.
#cs
功能:收集计算机上已经打的补丁

问题:
1.Dim几个变量在while循环内,只能收集1个已打补丁?
答:应该在While循环之前打开文件就OK。
#ce

Dim $FixedPatchsListPath=@ScriptDir & "\FixedPatchsList.ini"  
FileOpen($FixedPatchsListPath,8) ;8表示如果指定打开目录不存在那么强制建立它!          
While 1
        Dim $FixedPatchsRegPath="HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\HotFix"
        Dim $i
        $i += 1
        $Var=RegEnumKey($FixedPatchsRegPath,$i)
        If @error <>0  Then ExitLoop
        FileWriteLine($FixedPatchsListPath,$Var & @CRLF);将枚举出的值逐行写入到指定的ini文件中
WEnd
        FileClose($FixedPatchsListPath)
发表于 2010-8-9 16:58:57 | 显示全部楼层
回复 6# newuser


    你只理解了一半。你的代码FileOpen没起作用。
测试下你我代码所耗费的时间…
 楼主| 发表于 2010-8-9 17:34:28 | 显示全部楼层
回复 7# afan
为什么呢?难道是变量先定义的早用的效率就高?
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-10-3 12:25 , Processed in 0.096965 second(s), 28 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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