找回密码
 加入
搜索
查看: 2736|回复: 3

[效率算法] 查找绿色软件

[复制链接]
发表于 2010-12-7 10:49:50 | 显示全部楼层 |阅读模式
本帖最后由 wgboy 于 2010-12-7 10:54 编辑

以下代码可以取出注册表中正规软件安装信息
如何能查出电脑中的绿色软件啊。有没有好的正则表达之类。。
$i = 0
While 1
        $i = $i + 1
        $var = RegEnumKey("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall", $i)
        If @error <> 0 Then ExitLoop
WEnd

$iTotal = $i

For $i = 1 To $iTotal Step 1 ;对注册表进行扫描
        $var = RegEnumKey("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall", $i)
        If @error <> 0 Then ExitLoop

        $iRegExp = StringRegExp($var, 'KB\d\d\d\d', 0) ; 剔除操作系统更新包
        If $iRegExp = 1 Then
                ContinueLoop
        EndIf

        $SoftwareName = RegRead("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" & $var, "DisplayName") ; 剔除空的注册表键值
        If @error = -1 Then
                ContinueLoop
        EndIf

        If StringInStr($SoftwareName, "Microsoft Office", 0, 1) <> 0 And Not StringInStr($SoftwareName, "Visio", 0, 1) <> 0 And Not StringInStr($SoftwareName, "project", 0, 1) <> 0 Then
                ContinueLoop
        EndIf
        ; 提取安装软件的名称,版本和安装路径
        $SoftwareVersion = RegRead("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" & $var, "DisplayVersion")
        $len = StringLen($SoftwareVersion)
        ; 有些软件在注册表中的版本信息字段定义为Inno Setup: Setup Version
        If $len = 0 Then
                $SoftwareVersion = RegRead("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" & $var, "Inno Setup: Setup Version")
        EndIf

        ; 提取软件的名称、版本号和安装路径
        $SoftwareInstallLocation = RegRead("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" & $var, "InstallLocation")


        $len = StringLen($SoftwareInstallLocation)
        If $len = 0 Then
                $DisplayStr = RegRead("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" & $var, "Readme")
                $len = StringLen($DisplayStr)
                If $len = 0 Then
                        $DisplayStr = RegRead("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" & $var, "DisplayIcon")
                        $len = StringLen($DisplayStr)
                        If $len = 0 Then
                                $DisplayStr = RegRead("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" & $var, "UninstallString")
                        EndIf
                EndIf
                $len = StringLen($DisplayStr)
                If $len = 0 Then
                        ContinueLoop
                EndIf

                $array = StringSplit($DisplayStr, '\', 1)
                $num = $array[0] - 1
                For $j = 1 To $num
                        $SoftwareInstallLocation = $SoftwareInstallLocation & $array[$j] & ""
                Next

        EndIf ;<=== 提取软件的名称、版本号和安装路径 结束

        $SoftwareInstallLocation = StringRegExpReplace($SoftwareInstallLocation, '"', "")

        ; 去掉驱动程序和一些windows自带的软件包
        If StringInStr($SoftwareInstallLocation, "file:") <> 0 _
                        Or StringInStr($SoftwareInstallLocation, "MsiExec.exe") <> 0 _
                        Or StringInStr($SoftwareInstallLocation, "RunDll32") <> 0 _
                        Or StringInStr($SoftwareInstallLocation, "%ProgramFiles%") <> 0 _
                        Or StringInStr($SoftwareInstallLocation, "c:\windows") <> 0 _
                        Or StringInStr($SoftwareInstallLocation, "\Common Files") <> 0 _
                        Or StringInStr($SoftwareInstallLocation, "") = 0 Then
                ContinueLoop
        EndIf
发表于 2010-12-7 11:46:02 | 显示全部楼层
绿色软件要么不写注册表,要么就是随自己喜欢写到哪里,因为并不需要系统关联,一般就是些注册信息、配置信息。
发表于 2010-12-7 12:30:41 | 显示全部楼层
查出电脑中的绿色软件?不容易实现吧
发表于 2010-12-7 14:43:42 | 显示全部楼层
没办法。。。你用任何软件都做不到
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-4-27 15:10 , Processed in 0.080619 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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