#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 = "X86" Then
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 = "[WinXP.x86]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 = "[Win7.x86]WanDrv6.exe"
Case $osVer = "6.2"
TrayTip("", "系统架构为" & $osBit & @CRLF & "系统为 Windows 8 x86", 5, 1)
$DrvFileNmae = "[Win8.x86]WanDrv6.exe"
Case $osVer = "6.3"
TrayTip("", "系统架构为" & $osBit & @CRLF & "系统为 Windows 8.1 x86", 5, 1)
$DrvFileNmae = "[Win8.x86]WanDrv6.exe"
Case $osVer = "6.4"
TrayTip("", "系统架构为" & $osBit & @CRLF & "系统为 Windows 10 x86 beat", 5, 1)
$DrvVer = 1032
$DrvFileNmae = "[Win10.x86]WanDrv6.exe"
Case $osVer = "10.0"
TrayTip("", "系统架构为" & $osBit & @CRLF & "系统为 Windows 10 x86", 5, 1)
$DrvVer = 1032
$DrvFileNmae = "[Win10.x86]WanDrv6.exe"
EndSelect
ElseIf $osBit = "X64" Then
Select
Case $osVer = "5.1"
TrayTip("", "系统架构为" & $osBit & @CRLF & "系统为 Windows XP x64", 5, 1)
$DrvFileNmae = "none"
Case $osVer = "5.2"
TrayTip("", "系统架构为" & $osBit & @CRLF & "系统为 Windows Server 2003 x64", 5, 1)
$DrvFileNmae = "none"
Case $osVer = "6.0"
TrayTip("", "系统架构为" & $osBit & @CRLF & "系统为 Windows Vista x64", 5, 1)
$DrvFileNmae = "none"
Case $osVer = "6.1"
TrayTip("", "系统架构为" & $osBit & @CRLF & "系统为 Windows 7 x64", 5, 1)
$DrvFileNmae = "[Win7.x64]WanDrv6.exe"
Case $osVer = "6.2"
TrayTip("", "系统架构为" & $osBit & @CRLF & "系统为 Windows 8 x64", 5, 1)
$DrvFileNmae = "[Win8.x64]WanDrv6.exe"
Case $osVer = "6.3"
TrayTip("", "系统架构为" & $osBit & @CRLF & "系统为 Windows 8.1 x64", 5, 1)
$DrvFileNmae = "[Win8.x64]WanDrv6.exe"
Case $osVer = "6.4"
TrayTip("", "系统架构为" & $osBit & @CRLF & "系统为 Windows 10 beat x64", 5, 1)
$DrvVer = 1032
$DrvFileNmae = "[Win10.x64]WanDrv6.exe"
Case $osVer = "10.0"
TrayTip("", "系统架构为" & $osBit & @CRLF & "系统为 Windows 10 x64", 5, 1)
$DrvVer = 1064
$DrvFileNmae = "[Win10.x64]WanDrv6.exe"
EndSelect
ElseIf $osBit = "IA64" Then
MsgBox(64, "", "系统架构为" & $osBit & "!本程序不支持安腾处理器!", 10)
Exit
EndIf
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[0]
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