一个关于@ScriptDir的问题
本帖最后由 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
;读CPU数据
Local $CPU
$CPU=IniRead($EveRptFile,"CPU","CPU Properties|CPU Type","")
$EveRpt=$CPU
$EveRpt=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[$p]=$NorthBridge
$p+=1
EndIf
If $SouthBridge<>"" Then
$EveRpt[$p]=$SouthBridge
$p+=1
EndIf
EndIf
EndIf
$i+=1
WEnd
$EveRpt=$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[$p]=$Video
$p+=1
EndIf
EndIf
$i+=1
WEnd
$EveRpt=$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[$p]=$GPU
$p+=1
EndIf
EndIf
$i+=1
WEnd
$EveRpt=$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[$p]=$Audio
$p+=1
EndIf
EndIf
$i+=1
WEnd
$EveRpt=$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[$p]=$Network
$p+=1
EndIf
EndIf
$i+=1
WEnd
$EveRpt=$p-1
;简化数组元素
Local $Max=$EveRpt
Local $i
For $i=2 To UBound($EveRpt,1)-1
If $EveRpt[$i]>$Max Then
$Max=$EveRpt[$i]
EndIf
Next
ReDim $EveRpt[$Max+1]
Return $EveRpt
EndFunc
Func _EveRptToHdwType($EveRpt)
Local $HdwType
Local $i
For $i=1 To UBound($EveRpt,1)-1
$HdwType[$i]=$EveRpt[$i]
Next
;CPU信息转硬件类型
Select
Case StringInStr($EveRpt,"AMD")
$HdwType="AMD"
Case StringInStr($EveRpt,"Intel")
$HdwType="Intel"
EndSelect
;主板芯片信息转硬件类型
Local $j
For $j=1 To $EveRpt
Select
Case StringInStr($EveRpt[$j],"ALI") Or StringInStr($EveRpt[$j],"ULI")
$HdwType[$j]="ALI_ULI"
Case StringInStr($EveRpt[$j],"AMD") Or StringInStr($EveRpt[$j],"ATI")
$HdwType[$j]="AMD_ATI"
Case StringInStr($EveRpt[$j],"INTEL")
$HdwType[$j]="INTEL"
Case StringInStr($EveRpt[$j],"NVIDIA")
$HdwType[$j]="NVIDIA"
Case StringInStr($EveRpt[$j],"SIS")
$HdwType[$j]="SIS"
Case StringInStr($EveRpt[$j],"VIA")
$HdwType[$j]="VIA"
Case Else
$HdwType[$j]="Other"
EndSelect
Next
;显卡信息转硬件类型
Local $j
For $j=1 To $EveRpt
Select
Case StringInStr($EveRpt[$j],"AMD") Or StringInStr($EveRpt[$j],"ATI")
$HdwType[$j]="AMD_ATI"
Case StringInStr($EveRpt[$j],"INTEL")
$HdwType[$j]="INTEL"
Case StringInStr($EveRpt[$j],"Matrox")
$HdwType[$j]="Matrox"
Case StringInStr($EveRpt[$j],"NVIDIA")
$HdwType[$j]="NVIDIA"
Case StringInStr($EveRpt[$j],"SIS")
$HdwType[$j]="SIS"
Case StringInStr($EveRpt[$j],"VIA") Or StringInStr($EveRpt[$j],"S3")
$HdwType[$j]="VIA_S3"
Case StringInStr($EveRpt[$j],"VMWARE")
$HdwType[$j]="VMWARE"
Case Else
$HdwType[$j]="Other"
EndSelect
Next
;GPU信息转硬件类型
Local $j
For $j=1 To $EveRpt
Select
Case StringInStr($EveRpt[$j],"AMD") Or _
StringInStr($EveRpt[$j],"ATI") Or _
StringInStr($EveRpt[$j],"Radeon")
$HdwType[$j]="AMD_ATI"
Case StringInStr($EveRpt[$j],"INTEL")
$HdwType[$j]="INTEL"
Case StringInStr($EveRpt[$j],"Matrox")
$HdwType[$j]="Matrox"
Case StringInStr($EveRpt[$j],"NVIDIA") Or _
StringInStr($EveRpt[$j],"Geforce")
$HdwType[$j]="NVIDIA"
Case StringInStr($EveRpt[$j],"SIS")
$HdwType[$j]="SIS"
Case StringInStr($EveRpt[$j],"VIA") Or StringInStr($EveRpt[$j],"S3")
$HdwType[$j]="VIA_S3"
Case StringInStr($EveRpt[$j],"VMWARE")
$HdwType[$j]="VMWARE"
Case Else
$HdwType[$j]="Other"
EndSelect
Next
;声卡信息转硬件类型
Local $j
For $j=1 To $EveRpt
Select
Case StringInStr($EveRpt[$j],"Analog Devices")
$HdwType[$j]="ADI"
Case StringInStr($EveRpt[$j],"ATI") Or StringInStr($EveRpt[$j],"ATI")
$HdwType[$j]="AMD_ATI"
Case StringInStr($EveRpt[$j],"C-Media")
$HdwType[$j]="C-Media"
Case StringInStr($EveRpt[$j],"Conexant")
$HdwType[$j]="Conexant"
Case StringInStr($EveRpt[$j],"Creative")
$HdwType[$j]="Creative"
Case StringInStr($EveRpt[$j],"IDT") Or StringInStr($EveRpt[$j],"Sigmatel")
$HdwType[$j]="Sigmatel"
Case StringInStr($EveRpt[$j],"Realtek")
$HdwType[$j]="Realtek"
Case StringInStr($EveRpt[$j],"SIS")
$HdwType[$j]="SIS"
Case StringInStr($EveRpt[$j],"VIA")
$HdwType[$j]="VIA"
Case Else
$HdwType[$j]="Other"
EndSelect
Next
;网卡信息转硬件类型
Local $j
For $j=1 To $EveRpt
Select
Case StringInStr($EveRpt[$j],"3Com")
$HdwType[$j]="3Com"
Case StringInStr($EveRpt[$j],"AMD")
$HdwType[$j]="AMD"
Case StringInStr($EveRpt[$j],"Broadcom")
$HdwType[$j]="Broadcom"
Case StringInStr($EveRpt[$j],"D-Link")
$HdwType[$j]="D-Link"
Case StringInStr($EveRpt[$j],"Intel")
$HdwType[$j]="Intel"
Case StringInStr($EveRpt[$j],"Marvell")
$HdwType[$j]="Marvell"
Case StringInStr($EveRpt[$j],"nVIDIA")
$HdwType[$j]="nVIDIA"
Case StringInStr($EveRpt[$j],"Realtek")
$HdwType[$j]="Realtek"
Case StringInStr($EveRpt[$j],"SiS")
$HdwType[$j]="SiS"
Case StringInStr($EveRpt[$j],"TP-Link")
$HdwType[$j]="TP-Link"
Case StringInStr($EveRpt[$j],"ULI")
$HdwType[$j]="ULI"
Case StringInStr($EveRpt[$j],"VIA")
$HdwType[$j]="VIA"
Case Else
$HdwType[$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
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]=$p-1
Next
;简化数组元素
Local $Max=$tHdwType
Local $i
For $i=2 To UBound($tHdwType,1)-1
If $tHdwType[$i]>$Max Then
$Max=$tHdwType[$i]
EndIf
Next
ReDim $tHdwType[$Max+1]
Return $tHdwType
EndFunc
文件在WIN7桌面的情况下生成的reports不在Everest中,而是在我的文档中,而在D盘或者E盘就可以用了,我搜索了半天也没有解决的办法,希望大家给点意见,在论坛上关于此类问题我也看了,好像没有什么不对的地方。我想因该是@ScriptDir的问题,具体问题还是不知道。难道是我系统的环境变量的问题吗? 用环境变量看看如何! 不是太了解,能修改一下吗?谢谢了 大侠您的Example.au3
http://119.147.150.23/down_group166/M00/12/26/d5OWF07DV_AAAAAAAABGxUeZKKY4328321/201111161426200.jpg?k=-X9FGb7gxlcLHG3J4b312w&t=1321439408&u=123.5.121.125@16076696@clf0clbi&file=201111161426200.jpg
请看图中col 0列表如何变成对应的比如cpu,Chipset等名称 谢谢了 这个我还是不懂得,等慢慢研究吧我也是菜鸟 使用CMD命令时, 如果路径中包含有空格或是路径字符串大于8位时,
最好是用 FileGetShortName 函数转换一下, 不然有可能运行失败! 我也想知道是什么问题 我也想知道是什么问题 回复 8# xz00311
他的问题是,
程序的在win7的桌面上运行时,检测脚本当前目录下的一个文件夹,而建立 的文件夹会跑到我的文档目录中去,没在当前桌面目录中 楼主正解,希望大家能试一下,然后能给出结果,我真的没有办法了。 回复 4# weeks1
你用的什么系统呀,你放在桌面还是其他盘符呢!! 回复 11# dabaiyun
我用的是XP系统 放在了桌面
我的问题是 col 0 列表中1,2这些数据要如何变成对应的比如cpu,Chipset等名称 谢谢了
页:
[1]