找回密码
 加入
搜索
查看: 4283|回复: 11

[AU3基础] 一个关于@ScriptDir的问题

  [复制链接]
发表于 2011-11-16 07:40:53 | 显示全部楼层 |阅读模式
本帖最后由 dabaiyun 于 2011-11-17 12:45 编辑
#include <Array.au3>

_Main()
Exit

Func _Main()
        Local $r
        Local $EveRptFile
        $r=_CreateEverestReport()
        If $r==-1 Then
                MsgBox(0+16,"错误","Everest文件包存在问题!")
                Return
        ElseIf $r==0 Then
                MsgBox(0+16,"错误","Everest检测报告生成失败!")
                Return
        Else
                $EveRptFile=$r
        EndIf
        
        ;$EveRptFile=@ScriptDir&"\Everest\Reports\Report.ini"
        
        Local $EveRpt
        $EveRpt=_ReadEverestReport($EveRptFile)
        _ArrayDisplay($EveRpt)
        
        Local $HdwType
        $HdwType=_EveRptToHdwType($EveRpt)
        _ArrayDisplay($HdwType)
        
        $HdwType=_Tidy($HdwType)
        _ArrayDisplay($HdwType)
EndFunc
        
Func _CreateEverestReport()
        
        ;设定Everest文件包所在位置
        Local $EveDir=@ScriptDir&"\Everest"        
        ;Local $Cmd = @ComSpec & " /c " & '"' & _
                        ;@ScriptDir & "\Everest\Everest.exe" & _
                        ;" /r /custom user.rpf /ini report.ini /silent" & '"'
        ;检测并确认所有必须的文件都存在
        If Not(FileExists($EveDir)) Then Return -1
        If Not(FileExists($EveDir&"\everest.dat")) Then Return -1
        If Not(FileExists($EveDir&"\everest.exe")) Then Return -1
        If Not(FileExists($EveDir&"\everest.exe.manifest")) Then Return -1
        If Not(FileExists($EveDir&"\everest.mem")) Then Return -1
        If Not(FileExists($EveDir&"\kerneld.amd64")) Then Return -1
        If Not(FileExists($EveDir&"\kerneld.ia64")) Then Return -1
        If Not(FileExists($EveDir&"\kerneld.w9x")) Then Return -1
        If Not(FileExists($EveDir&"\kerneld.wnt")) Then Return -1
        If Not(FileExists($EveDir&"\pkey.txt")) Then Return -1
        If Not(FileExists($EveDir&"\User.rpf")) Then Return -1
        
        ;扫描硬件
        TrayTip("硬件扫描","正在扫描硬件...","",1)
        RunWait($EveDir&"\everest.exe"&" /r /custom user.rpf /ini report.ini /silent", $EveDir, @SW_HIDE)
        TrayTip("","","")
        
        ;检查硬件检测报告是否生成成功
        If FileExists($EveDir&"\Reports\Report.ini") Then
                Return $EveDir&"\Reports\Report.ini"
        Else
                Return 0
        EndIf
EndFunc
        
Func _ReadEverestReport($EveRptFile)
        Local $EveRpt[7][21]
        
        ;读CPU数据
        Local $CPU
        $CPU=IniRead($EveRptFile,"CPU","CPU Properties|CPU Type","")
        $EveRpt[1][1]=$CPU
        $EveRpt[1][0]=1
        
        ;读Chipset数据        
        Local $i=1,$p=1
        While 1
                Local $NorthBridge,$SouthBridge
                $NorthBridge=IniRead($EveRptFile,"Chipset","Chipset"&$i&"|North Bridge Properties|North Bridge","")
                $SouthBridge=IniRead($EveRptFile,"Chipset","Chipset"&$i&"|South Bridge Properties|South Bridge","")
                If $NorthBridge="" And $SouthBridge="" Then
                        ExitLoop
                Else
                        If $p>=UBound($EveRpt,2) Then
                                ExitLoop
                        Else
                                If $NorthBridge<>"" Then
                                        $EveRpt[2][$p]=$NorthBridge
                                        $p+=1
                                EndIf
                                If $SouthBridge<>"" Then
                                        $EveRpt[2][$p]=$SouthBridge
                                        $p+=1                                        
                                EndIf
                        EndIf
                EndIf
                $i+=1
        WEnd
        $EveRpt[2][0]=$p-1
        
        ;读Video数据
        Local $i=1,$p=1
        While 1
                Local $Video
                $Video=IniRead($EveRptFile,"PCI / AGP Video","PCI / AGP Video"&$i,"")
                If $Video="" Then
                        ExitLoop
                Else
                        If $p>=UBound($EveRpt,2) Then
                                ExitLoop
                        Else
                                $EveRpt[3][$p]=$Video
                                $p+=1
                        EndIf
                EndIf
                $i+=1
        WEnd
        $EveRpt[3][0]=$p-1
        
        ;读GPU数据
        Local $i=1,$p=1
        While 1
                Local $GPU
                $GPU=IniRead($EveRptFile,"GPU","GPU"&$i&"|Graphics Processor Properties|Video Adapter","")
                If $GPU="" Then
                        ExitLoop
                Else
                        If $p>=UBound($EveRpt,2) Then
                                ExitLoop
                        Else
                                $EveRpt[4][$p]=$GPU
                                $p+=1
                        EndIf
                EndIf
                $i+=1
        WEnd
        $EveRpt[4][0]=$p-1        

        ;读Audio数据
        Local $i=1,$p=1
        While 1
                Local $Audio
                $Audio=IniRead($EveRptFile,"PCI / PnP Audio","PCI / PnP Audio"&$i,"")
                If $Audio="" Then
                        ExitLoop
                Else
                        If $p>=UBound($EveRpt,2) Then
                                ExitLoop
                        Else
                                Local $Loc=StringInStr($Audio,"@")
                                If $Loc>0 Then
                                        $Audio=StringTrimRight($Audio,StringLen($Audio)-$Loc+1)
                                EndIf
                                $EveRpt[5][$p]=$Audio
                                $p+=1
                        EndIf
                EndIf
                $i+=1
        WEnd
        $EveRpt[5][0]=$p-1        

        ;读Network数据
        Local $i=1,$p=1
        While 1
                Local $Network
                $Network=IniRead($EveRptFile,"PCI / PnP Network","PCI / PnP Network"&$i,"")
                If $Network="" Then
                        ExitLoop
                Else
                        If $p>=UBound($EveRpt,2) Then
                                ExitLoop
                        Else
                                $EveRpt[6][$p]=$Network
                                $p+=1
                        EndIf
                EndIf
                $i+=1
        WEnd
        $EveRpt[6][0]=$p-1        
        
        ;简化数组元素
        Local $Max=$EveRpt[1][0]
        Local $i
        For $i=2 To UBound($EveRpt,1)-1
                If $EveRpt[$i][0]>$Max Then
                        $Max=$EveRpt[$i][0]
                EndIf
        Next
        ReDim $EveRpt[7][$Max+1]
        
        Return $EveRpt
EndFunc
        
Func _EveRptToHdwType($EveRpt)
        Local $HdwType[UBound($EveRpt,1)][UBound($EveRpt,2)]
        Local $i
        For $i=1 To UBound($EveRpt,1)-1
                $HdwType[$i][0]=$EveRpt[$i][0]
        Next
        
        ;CPU信息转硬件类型
        Select
                Case StringInStr($EveRpt[1][1],"AMD")
                        $HdwType[1][1]="AMD"
                Case StringInStr($EveRpt[1][1],"Intel")
                        $HdwType[1][1]="Intel"
        EndSelect
        
        ;主板芯片信息转硬件类型
        Local $j
        For $j=1 To $EveRpt[2][0]
                Select 
                        Case StringInStr($EveRpt[2][$j],"ALI") Or StringInStr($EveRpt[2][$j],"ULI")
                                $HdwType[2][$j]="ALI_ULI"
                        Case StringInStr($EveRpt[2][$j],"AMD") Or StringInStr($EveRpt[2][$j],"ATI")
                                $HdwType[2][$j]="AMD_ATI"
                        Case StringInStr($EveRpt[2][$j],"INTEL")
                                $HdwType[2][$j]="INTEL"
                        Case StringInStr($EveRpt[2][$j],"NVIDIA")
                                $HdwType[2][$j]="NVIDIA"
                        Case StringInStr($EveRpt[2][$j],"SIS")
                                $HdwType[2][$j]="SIS"
                        Case StringInStr($EveRpt[2][$j],"VIA")
                                $HdwType[2][$j]="VIA"
                        Case Else
                                $HdwType[2][$j]="Other"
                EndSelect
        Next
        
        ;显卡信息转硬件类型
        Local $j
        For $j=1 To $EveRpt[3][0]
                Select
                        Case StringInStr($EveRpt[3][$j],"AMD") Or StringInStr($EveRpt[3][$j],"ATI")
                                $HdwType[3][$j]="AMD_ATI"
                        Case StringInStr($EveRpt[3][$j],"INTEL")
                                $HdwType[3][$j]="INTEL"
                        Case StringInStr($EveRpt[3][$j],"Matrox")
                                $HdwType[3][$j]="Matrox"
                        Case StringInStr($EveRpt[3][$j],"NVIDIA")
                                $HdwType[3][$j]="NVIDIA"
                        Case StringInStr($EveRpt[3][$j],"SIS")
                                $HdwType[3][$j]="SIS"
                        Case StringInStr($EveRpt[3][$j],"VIA") Or StringInStr($EveRpt[3][$j],"S3")
                                $HdwType[3][$j]="VIA_S3"
                        Case StringInStr($EveRpt[3][$j],"VMWARE")
                                $HdwType[3][$j]="VMWARE"
                        Case Else
                                $HdwType[3][$j]="Other"
                EndSelect
        Next
        
        ;GPU信息转硬件类型
        Local $j
        For $j=1 To $EveRpt[4][0]
                Select
                        Case StringInStr($EveRpt[4][$j],"AMD") Or _ 
                                StringInStr($EveRpt[4][$j],"ATI") Or _ 
                                StringInStr($EveRpt[4][$j],"Radeon")
                                $HdwType[4][$j]="AMD_ATI"
                        Case StringInStr($EveRpt[4][$j],"INTEL")
                                $HdwType[4][$j]="INTEL"
                        Case StringInStr($EveRpt[4][$j],"Matrox")
                                $HdwType[4][$j]="Matrox"
                        Case StringInStr($EveRpt[4][$j],"NVIDIA") Or _
                                StringInStr($EveRpt[4][$j],"Geforce")
                                $HdwType[4][$j]="NVIDIA"
                        Case StringInStr($EveRpt[4][$j],"SIS")
                                $HdwType[4][$j]="SIS"
                        Case StringInStr($EveRpt[4][$j],"VIA") Or StringInStr($EveRpt[4][$j],"S3")
                                $HdwType[4][$j]="VIA_S3"
                        Case StringInStr($EveRpt[4][$j],"VMWARE")
                                $HdwType[4][$j]="VMWARE"
                        Case Else
                                $HdwType[4][$j]="Other"
                EndSelect
        Next
                        
        ;声卡信息转硬件类型
        Local $j
        For $j=1 To $EveRpt[5][0]
                Select
                        Case StringInStr($EveRpt[5][$j],"Analog Devices")
                                $HdwType[5][$j]="ADI"
                        Case StringInStr($EveRpt[5][$j],"ATI") Or StringInStr($EveRpt[5][$j],"ATI")
                                $HdwType[5][$j]="AMD_ATI"
                        Case StringInStr($EveRpt[5][$j],"C-Media")
                                $HdwType[5][$j]="C-Media"
                        Case StringInStr($EveRpt[5][$j],"Conexant")
                                $HdwType[5][$j]="Conexant"
                        Case StringInStr($EveRpt[5][$j],"Creative")
                                $HdwType[5][$j]="Creative"
                        Case StringInStr($EveRpt[5][$j],"IDT") Or StringInStr($EveRpt[5][$j],"Sigmatel")
                                $HdwType[5][$j]="Sigmatel"
                        Case StringInStr($EveRpt[5][$j],"Realtek")
                                $HdwType[5][$j]="Realtek"                                                                
                        Case StringInStr($EveRpt[5][$j],"SIS")
                                $HdwType[5][$j]="SIS"
                        Case StringInStr($EveRpt[5][$j],"VIA")
                                $HdwType[5][$j]="VIA"
                        Case Else
                                $HdwType[5][$j]="Other"
                EndSelect
        Next
        
        ;网卡信息转硬件类型
        Local $j
        For $j=1 To $EveRpt[6][0]        
                Select
                        Case StringInStr($EveRpt[6][$j],"3Com")
                                $HdwType[6][$j]="3Com"
                        Case StringInStr($EveRpt[6][$j],"AMD")
                                $HdwType[6][$j]="AMD"                                
                        Case StringInStr($EveRpt[6][$j],"Broadcom")
                                $HdwType[6][$j]="Broadcom"                                
                        Case StringInStr($EveRpt[6][$j],"D-Link")
                                $HdwType[6][$j]="D-Link"                                
                        Case StringInStr($EveRpt[6][$j],"Intel")
                                $HdwType[6][$j]="Intel"                                
                        Case StringInStr($EveRpt[6][$j],"Marvell")
                                $HdwType[6][$j]="Marvell"
                        Case StringInStr($EveRpt[6][$j],"nVIDIA")
                                $HdwType[6][$j]="nVIDIA"
                        Case StringInStr($EveRpt[6][$j],"Realtek")
                                $HdwType[6][$j]="Realtek"
                        Case StringInStr($EveRpt[6][$j],"SiS")
                                $HdwType[6][$j]="SiS"
                        Case StringInStr($EveRpt[6][$j],"TP-Link")
                                $HdwType[6][$j]="TP-Link"
                        Case StringInStr($EveRpt[6][$j],"ULI")
                                $HdwType[6][$j]="ULI"
                        Case StringInStr($EveRpt[6][$j],"VIA")
                                $HdwType[6][$j]="VIA"
                        Case Else
                                $HdwType[6][$j]="Other"
                EndSelect
        Next
        
        Return $HdwType
EndFunc

Func _Tidy($HdwType)
        
        ;将相同的类型去掉
        Local $i,$j,$k
        For $i=1 To UBound($HdwType,1)-1
                For $j=1 To UBound($HdwType,2)-2
                        For $k=$j+1 To UBound($HdwType,2)-1
                                If $HdwType[$i][$j]=$HdwType[$i][$k] Then
                                        $HdwType[$i][$k]=""
                                EndIf
                        Next
                Next
        Next
        
        ;整理数组
        Local $tHdwType[UBound($HdwType,1)][UBound($HdwType,2)]
        Local $i
        For $i=1 To UBound($HdwType,1)-1
                Local $p=1
                For $j=1 To UBound($HdwType,2)-1
                        If $HdwType[$i][$j]<>"" Then
                                $tHdwType[$i][$p]=$HdwType[$i][$j]
                                $p+=1
                        EndIf
                Next
                $tHdwType[$i][0]=$p-1
        Next
        
        ;简化数组元素
        Local $Max=$tHdwType[1][0]
        Local $i
        For $i=2 To UBound($tHdwType,1)-1
                If $tHdwType[$i][0]>$Max Then
                        $Max=$tHdwType[$i][0]
                EndIf
        Next
        ReDim $tHdwType[UBound($HdwType,1)][$Max+1]
        
        Return $tHdwType
EndFunc
        
文件在WIN7桌面的情况下生成的reports不在Everest中,而是在我的文档中,而在D盘或者E盘就可以用了,我搜索了半天也没有解决的办法,希望大家给点意见,在论坛上关于此类问题我也看了,好像没有什么不对的地方。我想因该是@ScriptDir的问题,具体问题还是不知道。难道是我系统的环境变量的问题吗?

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
发表于 2011-11-16 09:17:26 | 显示全部楼层
用环境变量看看如何!
 楼主| 发表于 2011-11-16 12:46:00 | 显示全部楼层
不是太了解,能修改一下吗?谢谢了
发表于 2011-11-16 14:38:10 | 显示全部楼层
大侠您的Example.au3

请看图中col 0列表如何变成对应的比如cpu,Chipset等名称 谢谢了

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
 楼主| 发表于 2011-11-16 18:34:03 | 显示全部楼层
这个我还是不懂得,等慢慢研究吧我也是菜鸟
发表于 2011-11-16 23:07:23 | 显示全部楼层
使用CMD命令时, 如果路径中包含有空格或是路径字符串大于8位时,
最好是用 FileGetShortName 函数转换一下, 不然有可能运行失败!
发表于 2011-11-17 00:39:18 | 显示全部楼层
我也想知道是什么问题
发表于 2011-11-17 00:39:45 | 显示全部楼层
我也想知道是什么问题
发表于 2011-11-17 00:57:24 | 显示全部楼层
回复 8# xz00311

他的问题是,

  程序的在win7的桌面上运行时,检测脚本当前目录下的一个文件夹,而建立 的文件夹会跑到我的文档目录中去,没在当前桌面目录中
 楼主| 发表于 2011-11-17 07:00:05 | 显示全部楼层
楼主正解,希望大家能试一下,然后能给出结果,我真的没有办法了。
 楼主| 发表于 2011-11-17 07:06:14 | 显示全部楼层
回复 4# weeks1


    你用的什么系统呀,你放在桌面还是其他盘符呢!!
发表于 2011-11-17 07:29:20 | 显示全部楼层
回复 11# dabaiyun

我用的是XP系统 放在了桌面
我的问题是 col 0 列表中1,2这些数据要如何变成对应的比如cpu,Chipset等名称 谢谢了
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-9-20 21:38 , Processed in 0.107702 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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