4#再次修改了,我这没办法测试
afan 发表于 2014-12-22 14:46 http://www.autoitx.com/images/common/back.gif
谢谢你!高人,测试通过,可以讲解下你加的那个语句吗?
我尝试加入更多功能——优先搜索当前目录、全盘搜索有多个不同版本驱动优先使用文件日期较后的版本、如果是win10先搜索WanDrv6.exe搜不到就用win8驱动代替,如果不会,还请继续指教,谢谢 代码精简了下:#include <file.au3>
Dim $osVersion, $osVer, $osBit, $DrvVer, $DrvFileNmae, $DriverNumber
$osVersion = FileGetVersion(@WindowsDir & "\system32\kernel32.dll")
$osVer = StringLeft($osVersion, 3)
MsgBox(0, 0, '"' & $osVer & '"')
$osBit = @OSArch
$DriverNumber = DriveGetDrive("all")
TrayTip("", "检测操作系统版本,请稍候...", 5, 1)
If $osBit = "IA64" Then
MsgBox(64, "", "系统架构为" & $osBit & "!本程序不支持安腾处理器!", 10)
Exit
EndIf
Select
Case $osVer = "5.0"
TrayTip("", "系统架构为" & $osBit & @CRLF & "系统为 Windows 2000", 5, 1)
$DrvFileNmae = "none"
Case $osVer = "5.1"
TrayTip("", "系统架构为" & $osBit & @CRLF & "系统为 Windows XP x86", 5, 1)
$DrvFileNmae = "WanDrv6.exe"
Case $osVer = "5.2"
TrayTip("", "系统架构为" & $osBit & @CRLF & "系统为 Windows Server 2003 x86", 5, 1)
$DrvFileNmae = "none"
Case $osVer = "6.0"
TrayTip("", "系统架构为" & $osBit & @CRLF & "系统为 Windows Vista x86", 5, 1)
$DrvFileNmae = "none"
Case $osVer = "6.1"
TrayTip("", "系统架构为" & $osBit & @CRLF & "系统为 Windows 7 x86", 5, 1)
$DrvFileNmae = "WanDrv6.exe"
Case $osVer = "6.2"
TrayTip("", "系统架构为" & $osBit & @CRLF & "系统为 Windows 8 x86", 5, 1)
$DrvFileNmae = "WanDrv6.exe"
Case $osVer = "6.3"
TrayTip("", "系统架构为" & $osBit & @CRLF & "系统为 Windows 8.1 x86", 5, 1)
$DrvFileNmae = "WanDrv6.exe"
Case $osVer = "6.4"
TrayTip("", "系统架构为" & $osBit & @CRLF & "系统为 Windows 10 x86 beat", 5, 1)
$DrvVer = 1032
$DrvFileNmae = "WanDrv6.exe"
Case $osVer = "10.0"
TrayTip("", "系统架构为" & $osBit & @CRLF & "系统为 Windows 10 x86", 5, 1)
$DrvVer = 1032
$DrvFileNmae = "WanDrv6.exe"
EndSelect
If $DrvFileNmae = "none" Or Not $DrvFileNmae Then
MsgBox(64, "", "没有当前系统的驱动安装程序~!" & @CRLF & "请确认你的系统为WinXP、Win7、Win8、Win10!", 10)
Exit
EndIf
If FileExists(@HomeDrive & "\" & "Drivers") Then
MsgBox(64, "", "已存在" & @HomeDrive & "盘下Drivers目录,3秒后删除...", 3)
FileSetAttrib(@HomeDrive & "\" & "Drivers", "-RASH")
DirRemove(@HomeDrive & "\" & "Drivers", 1)
EndIf
If Not @error Then
For $i = 1 To $DriverNumber
FindAllFile(StringUpper($DriverNumber[$i]), $DrvFileNmae)
If IsDeclared("~" & StringToBinary($DrvFileNmae)) Then ExitLoop
Next
If Not IsDeclared("~" & StringToBinary($DrvFileNmae)) Then
MsgBox(64, "", "未找到驱动安装程序!" & @CRLF & "请确认下载自由天空驱动包并解压(任意位置均可)...", 5)
EndIf
EndIf
Func FindAllFile($sDir, $FName)
If IsDeclared("~" & StringToBinary($FName)) Then Return
Local $hSearch = FileFindFirstFile($sDir & "\*.*")
If $hSearch = -1 Then Return
While 1
Local $sFile = FileFindNextFile($hSearch)
If @error Then ExitLoop
If @extended Then
FindAllFile($sDir & "\" & $sFile, $FName)
ContinueLoop
EndIf
If $sFile = $FName Then
Assign("~" & StringToBinary($FName), 1, 2)
MsgBox(64, "", "找到驱动安装程序:" & $sDir & "\" & $sFile & @CRLF & "3秒之后开始安装驱动...", 3)
Run($sDir & "\" & $sFile)
ExitLoop
EndIf
WEnd
FileClose($hSearch)
EndFunc ;==>FindAllFile {:face (427):}学习了 来学习学习 观一下,学习一下,楼主好人
页:
1
[2]