#include <GUIConstantsEx.au3>
GUICreate("系统安装",185,145)
Dim $ISO
$ISO = FileFindFirstFile("*.IS?")
If $ISO = -1 Then
MsgBox(0,"错误","没有发现系统镜像文件!")
Exit
EndIf
If Not FileExists("ISOCmd.exe") And Not FileExists("ISODrive.sys") Then
MsgBox(0,"错误","没有发现虚拟光驱程序!")
Exit
Else
RunWait("ISOCmd.exe -r","",@SW_HIDE)
EndIf
Dim $FF,$FS[32],$NF
$FF = FileFindNextFile($ISO)
For $i = 1 to 31 Step 1
$FS[$i] = FileFindNextFile($ISO)
If @error Then
ExitLoop
Else
$FS[0] = $i
EndIf
Next
FileClose($ISO)
For $i = 1 To $FS[0] Step 1
$NF = $NF & $FS[$i]
If $i <> $FS[0] Then $NF = $NF & "|"
Next
GUICtrlCreateLabel("系统镜像:",15,15)
$ComboList_1 = GUICtrlCreateCombo($FF,75,12,98)
If $FS[0] > 0 Then GUICtrlSetData(-1,$NF)
$Combo1 = GUICtrlRead($ComboList_1)
$DriveList = DriveGetDrive("FIXED")
If @error Then Exit
Dim $List
For $i=2 To $DriveList[0] Step 1
$List = $List & StringUpper($DriveList[$i])
If $i <> $DriveList[0] Then $List = $List & "|"
Next
GUICtrlCreateLabel("虚拟光驱:",15,40)
Dim $all,$j,$k,$l,$v
$all = DriveGetDrive("all")
If Not @error Then
For $i = 1 To $all[0]
$j = $j & $all[$i]
Next
EndIf
For $i = 122 To 99 Step -1
If Not StringInStr($j,Chr($i)) Then $k = $k & Chr($i-32) & ":|"
Next
$l = StringSplit($k,"|")
For $i = 2 To $l[0] Step 1
$v = $v & $l[$i]
If $i < $l[0]-1 Then $v = $v & "|"
Next
$ComboList_2 = GUICtrlCreateCombo($l[1],75,37,38)
GUICtrlSetData(-1,$v,$l[0])
$Combo2 = GUICtrlRead($ComboList_2)
$Checkbox_1 = GUICtrlCreateCheckbox("IAR",120,37,55,20)
GUICtrlCreateLabel("启动分区:",15,65)
$ComboList_3 = GUICtrlCreateCombo(StringUpper($DriveList[1]),75,62,38)
GUICtrlSetData(-1,$List,$DriveList[1])
$Combo3 = GUICtrlRead($ComboList_3)
$Checkbox_2 = GUICtrlCreateCheckbox("重 启",120,62,55,20)
GUICtrlCreateLabel("安装分区:",15,90)
$ComboList_4 = GUICtrlCreateCombo(StringUpper($DriveList[1]),75,87,38)
GUICtrlSetData(-1,$List,$DriveList[1])
$Combo4 = GUICtrlRead($ComboList_4)
$Checkbox_3 = GUICtrlCreateCheckbox("格式化",120,87,55,20)
$Checkbox_4 = GUICtrlCreateCheckbox("运行安装程序",15,115,88,20)
$Button = GUICtrlCreateButton("开始",120,113,55)
GUICtrlSetState($Checkbox_1,$GUI_DISABLE)
GUICtrlSetState($Checkbox_2,$GUI_DISABLE)
GUICtrlSetState($Checkbox_3,1)
GUICtrlSetState($Checkbox_4,1)
GUICtrlSetState($Button,$GUI_FOCUS)
GUISetState()
While 1
$msg = GUIGetMsg()
If $msg = $GUI_EVENT_CLOSE Then ExitLoop
$Combo1 = GUICtrlRead($ComboList_1)
$Combo2 = GUICtrlRead($ComboList_2)
$Combo3 = GUICtrlRead($ComboList_3)
$Combo4 = GUICtrlRead($ComboList_4)
$Check1 = GUICtrlRead($Checkbox_1)
$Check2 = GUICtrlRead($Checkbox_2)
$Check3 = GUICtrlRead($Checkbox_3)
$Check4 = GUICtrlRead($Checkbox_4)
If $Check2 = 1 Then GUICtrlSetState($Checkbox_4,1)
$drive = Asc($Combo3)-Asc("A:")
If $msg = $Button Then
GUICtrlSetState($Button,$GUI_DISABLE)
If $Check3 = 1 Then DllCall("shell32.dll","uint","SHFormatDrive","hwnd",0,"uint",$drive,"uint",65535,"uint",1)
RunWait("ISOCmd.exe -i","",@SW_HIDE)
RunWait("ISOCmd.exe -n 1","",@SW_HIDE)
RunWait("ISOCmd.exe -c 1 " & $Combo2,"",@SW_HIDE)
RunWait(Chr(34) & "ISOCmd.exe" & Chr(34) & " -m " & $Combo2 & " " & Chr(34) & @ScriptDir & "" & $Combo1 & Chr(34),"",@SW_HIDE)
For $i = 1 To 10
If FileExists($Combo2 & "\I386\WINNT32.EXE") Then
ExitLoop
Else
If $i = 10 Then
MsgBox("","退出","没有发现系统的安装文件!")
Exit
EndIf
EndIf
Sleep(1000)
Next
$norb = ""
If $Check2 = 4 Then $norb = " /noreboot"
If $Check4 = 1 Then Run($Combo2 & "\I386\WINNT32.EXE /s:" & $Combo2 & "\I386 /makelocalsource /syspart:" & $Combo3 & " /tempdrive:" & $Combo4 & " /unattend:" & $Combo2 & "\I386\WINNT.SIF /copysource:lang" & $norb)
If FileExists($Combo2 & "\OEM") Then DirCopy($Combo2 & "\OEM",$Combo4 & "\OEM",1)
Exit
EndIf
WEnd