📄 winsetupfromusb_0-1-1.au3
字号:
For $objLogicalDisk In $colLogicalDisks
Logging( "Found USB Logical Disk: " & $objLogicalDisk.DeviceID & " File system: " & $objLogicalDisk.FileSystem _
& " Bootable: " & $objPartition.Bootable)
$NrOfFoundUSB += 1
$USBDlettersInfo[0][0] = $NrOfFoundUSB
ReDim $USBDlettersInfo[$NrOfFoundUSB + 1][9]
$USBDlettersInfo[$NrOfFoundUSB][0] = $objLogicalDisk.DeviceID
$USBDlettersInfo[$NrOfFoundUSB][1] = StringReplace($objDrive.Caption, "USB device", "")
$dp = StringSplit($objPartition.DeviceID, ",")
$USBDlettersInfo[$NrOfFoundUSB][2] = StringRegExpReplace($dp[1], "[^0-9]", "")
$USBDlettersInfo[$NrOfFoundUSB][3] = StringRegExpReplace($dp[2], "[^0-9]", "")
$USBDlettersInfo[$NrOfFoundUSB][4] = Round(DriveSpaceTotal($objLogicalDisk.DeviceID), 0)
$USBDlettersInfo[$NrOfFoundUSB][5] = Round(DriveSpaceFree($objLogicalDisk.DeviceID), 0)
$USBDlettersInfo[$NrOfFoundUSB][6] = DriveGetType($objLogicalDisk.DeviceID)
$USBDlettersInfo[$NrOfFoundUSB][7] = $objLogicalDisk.FileSystem
;$USBDlettersInfo[$NrOfFoundUSB][8] = $objPartition.BootPartition
$USBDlettersInfo[$NrOfFoundUSB][8] = $objPartition.Bootable
;array is in format--> DriveLetter | Name | Disk# | Part# | TotalSpace | FreeSpace | DriveType | FileSystem | Bootable(-1) or Not (0)
Next
Next
EndIf
Next
Return $USBDlettersInfo
EndFunc ;==>__GetUSBDrivesInfo()
;===================================================================================================
Func GetComboUSBSelection()
Local $i
$LastGroupUsed = "UsbDrive"
$curSelectTarget = _GUICtrlComboBox_GetCurSel($ComboBoxTarget) + 1
;_ArrayDisplay ($USBdrives)
If $USBdrives[$curSelectTarget][6] = "Fixed" Then
GUICtrlSetState($FixedRadio, $GUI_CHECKED)
ElseIf $USBdrives[$curSelectTarget][6] = "Removable" Then
GUICtrlSetState($RemovableRadio, $GUI_CHECKED)
Else
If $USBdrives[0][0] > 0 Then
If GUICtrlRead($ComboBoxTarget) <> "" Then
MsgBox(48, "Disk not properly formated", "Target disk doesn't seem to be FIXED or REMOVABLE, or it is not properly formated." _
& @CRLF & "Please select a valid target or insert another USB disk and click REFRESH button")
Return
Else
MsgBox(48, "Disk not properly formated", "USB disk doesn't seem to be properly formated or doesn't have an active partition." _
& @CRLF & "Please select a valid target or insert another USB disk and click REFRESH button" )
Return
EndIf
EndIf
EndIf
If $USBdrives[$curSelectTarget][2] > 9 Then
MsgBox(48, "Too many disks", "You seem to have too many hard disks, or you have a card reader connected." _
& @CRLF & "Cannot yet install Grub4Dos bootsector if hard disk number > 9" & @CRLF _
& "If you have a card reader please disconnect or disable it and click on REFRESH button")
Return
EndIf
$TargetDrive=$USBdrives[$curSelectTarget][0]
;ConsoleWrite($TargetDrive & @CRLF)
$USBdrives[0][1]= $curSelectTarget
$TargetSpaceAvail = $USBdrives[$curSelectTarget][5]
If $USBdrives[0][0] > 0 Then
For $i =1 To $USBdrives[0][0]
If $USBdrives[$i][2] = $USBdrives[$curSelectTarget][2] Then
If $USBdrives[$i][8] = -1 Then
$USBdrives[0][2] = $USBdrives[$i][3]
$USBdrives[0][3] = $USBdrives[$i][0]
$USBdrives[0][4] = $i
EndIf
EndIf
Next
If $USBdrives[0][4] = "" Then
MsgBox(48, "Could not find active partition of the selected disk!", "Please insert USB disk with an active partition and click Refresh button.", 10)
EndIf
EndIf
$TargetActive = $USBdrives[0][3]
Logging ("Target drive selected- " & $TargetDrive)
Logging ("Drive letter of the active partition in selected disk- " & $TargetActive)
Logging ("Total target size avialable- " & $TargetSpaceAvail & " MB")
_GUICtrlStatusBar_SetText($hStatus, Round($TargetSpaceAvail) & "MB", 1)
If $USBdrives[0][0] > 0 Then
If FileExists($GPartedSource & "\LIVE\") And $USBdrives[$USBdrives[0][1]][7] = "NTFS" Then
$Msg=MsgBox(48,"Error!", "This version of GParted won't work from NTFS partition!")
GUICtrlSetState($AddGPartedCheck, $GUI_UNCHECKED)
EnableInputBox()
EndIf
EndIf
;_ArrayDisplay ($USBdrives)
;$USBdrives is in format--> DriveLetter | Name | Disk# | Part# | TotalSpace | FreeSpace | DriveType | FileSystem | Bootable(-1) or Not (0)
;$USBdrives[0][0]- number of found partitions, $USBdrives[0][1]- currently selected number in this array; $USBdrives[0][2]- number of the active partition of this drive
;$USBdrives[0][3]- the letter of the active partition, $USBdrives[0][4]- the number in array with the active partition for the selected disk
EndFunc ;==>_GetComboUSBSelection()
;===================================================================================================
Func GetSource() ; Get Windows setup source folder
Local $Msg, $CheckFile, $TempWinSource1="", $UserExec
$LastGroupUsed = "WinSource"
$CheckFile=""
While 1
$TempWinSource = FileSelectFolder("Select Windows source, where folder I386 can be found","")
If @error = 1 Then
$TempWinSource = $WinSource
ExitLoop ;exit if cancel is pressed
EndIf
If StringLen($TempWinSource) = 3 Then $TempWinSource = StringLeft($TempWinSource, 2)
If FileExists($TempWinSource & "\AMD64\dosnet.inf") Then
If Not FileExists($TempWinSource&"\AMD64\winnt32.exe") Then
$Msg = MsgBox(48+5,"WINNT32.EXE could not be found",@CRLF & "'WINNT32.EXE' could not be found!" _
& @CRLF & "If you used Nlite to slim down source, the option 'MANUAL SETUP and UPGRADE'" _
& "in 'Operating System Options' must NOT be used!" _
& @CRLF & "RETRY to select a valid source or CANCEL to return to the main menu")
If $Msg = 4 Then
ContinueLoop
Else
ExitLoop
EndIf
Else
If CheckSize() = 1 Then
$UserExec = IniRead($TempWinSource1 & "\winnt.sif", "SetupParams", "UserExecute", "")
If $UserExec <> "" Then
Logging("Section SetupParams was found")
$msg = MsgBox(48+4, "Section SetupParams was found", "Section SetupParams was found in WINNT.SIF." _
& $UserExec & "will be replaced with ren_fold.cmd." & @CRLF & "You may execute the file adding it to ren_fold.cmd in ~BT folder" _
& @CRLF & @CRLF & "Continue ?")
If $msg <> 6 Then
Logging("Source was not selected because of SetupParams")
ExitLoop
EndIf
EndIf
$AMD64 = 1
$WinSource = $TempWinSource
$TempWinSource1 = $TempWinSource & "\AMD64"
GUICtrlSetData($Source, $WinSource)
ExitLoop
Else
$TempWinSource = $WinSource
$PrevWinSource = $WinSource
ExitLoop
EndIf
EndIf
ElseIf FileExists($TempWinSource&"\I386\dosnet.inf") Then
If Not FileExists($TempWinSource&"\I386\winnt32.exe") Then
$Msg=MsgBox(48+5,"WINNT32.EXE could not be found", "WINNT32.EXE could not be found!" _
& @CRLF & "If you used Nlite to slim down source the option 'MANUAL SETUP and UPGRADE'" _
& "in 'Operating System Options' must NOT be used !" _
& @CRLF & "RETRY to select a valid source or CANCEL to return to the main menu")
If $Msg=4 Then
ContinueLoop
Else
ExitLoop
EndIf
Else
If CheckSize() = 1 Then
$UserExec = IniRead($TempWinSource1 & "\winnt.sif", "SetupParams", "UserExecute", "")
If $UserExec <> "" Then
Logging("Section SetupParams was found")
$msg = MsgBox(48+4, "Section SetupParams was found", "Section SetupParams was found in WINNT.SIF." _
& $UserExec & "will be replaced with ren_fold.cmd." & @CRLF & "You may execute the file adding it to ren_fold.cmd in ~BT folder" _
& @CRLF & @CRLF & "Continue ?")
If $msg <> 6 Then
Logging("Source was not selected because of SetupParams")
ExitLoop
EndIf
EndIf
$AMD64 = 0
$WinSource = $TempWinSource
$TempWinSource1 = $TempWinSource & "\I386"
GUICtrlSetData($Source, $WinSource)
$PrevWinSource = $WinSource
ExitLoop
Else
$TempWinSource = $WinSource
ExitLoop
EndIf
EndIf
Else
$Msg=MsgBox(48+5,"Source is not valid", "This doesn't seem to be a valid source, could not find DOSNET.INF" _
& @CRLF & @CRLF & "RETRY to select a valid source or CANCEL to return to the main menu")
If $Msg=4 Then
ContinueLoop
Else
ExitLoop
EndIf
EndIf
ExitLoop
Wend
If $TempWinSource1 <> "" Then
$vers = IniRead($TempWinSource1&"\txtsetup.sif", "Strings", "productname", "NotFound")
$sp = StringReplace(IniRead($TempWinSource1&"\txtsetup.sif", "Strings", "spcdname", "NotFound"), "CD-ROM", "")
$sp = StringReplace($sp, "CD", "")
If StringInStr($vers, "XP") Or StringInStr($vers, "2003") Then GUICtrlSetData($WinTarget,"\WINDOWS")
;check for Windows 2000
If $vers = "NotFound" Then
$vers = StringReplace(IniRead($TempWinSource1&"\txtsetup.sif", "Strings", "wks_id", "NotFound"), "CD", "")
$sp = StringReplace(IniRead($TempWinSource1&"\txtsetup.sif", "Strings", "spcd", "NotFound"), "CD", "")
;update default BOOT.INI entry for Win 2000
If StringInStr($vers, "2000") Then
GUICtrlSetData($WinTarget,"\WINNT")
GUICtrlSetData($WinTargetAdd,"\WINNT")
EndIf
EndIF
EndIf
Logging("Windows source selected- " & $WinSource)
Logging("Source version- " & $vers)
Logging("Service Pack- " & $sp)
Logging("AMD64 flag- " & $AMD64)
EndFunc ;==>_GetSource()
;===================================================================================================
Func PEtoUSB() ; Format using PEtoUSB
Logging("PEtoUSB launched")
_GUICtrlStatusBar_SetText($hStatus,"Waiting for PEtoUSB to close", 2)
RunWait(@ScriptDir & "\files\tools\PeToUSB.exe")
Logging("PEtoUSB closed")
_GUICtrlStatusBar_SetText($hStatus,"Sleeping for 5 seconds before refreshing USB information", 2)
Sleep(5000)
PopulateUSBComboBox()
EndFunc
;===================================================================================================
Func FormatHP() ; Format using HP USB format tool
Logging("HP USB Disk Storage Format Tool launched")
_GUICtrlStatusBar_SetText($hStatus,"Waiting HP USB Disk Storage Format Tool to close", 2)
RunWait(@ScriptDir & "\files\tools\HPUSBFW.EXE")
Logging("HP USB Disk Storage Format Tool closed")
_GUICtrlStatusBar_SetText($hStatus,"Sleeping for 5 seconds before refreshing USB information", 2)
Sleep(5000)
PopulateUSBComboBox()
EndFunc ;==>_PEtoUSB()
;===================================================================================================
Func EnableInputBox()
Local $TempId
;MsgBox (1, @GUI_CtrlId, @GUI_CtrlId)
$TempId = @GUI_CtrlId
If $TempId = 19 Then $LastGroupUsed = "PE"
If $TempId = 22 Then $LastGroupUsed = "Vista"
If $TempId = 25 Then $LastGroupUsed = "GParted"
If $TempId = 28 Then $LastGroupUsed = "SysLinux"
If $TempId = 53 Then $LastGroupUsed = "BootOnly"
If GUICtrlRead($AddPECheck)=$GUI_CHECKED Then
GUICtrlSetState($AddPESource, $GUI_ENABLE)
GUICtrlSetState($AddPEBrowse, $GUI_ENABLE)
Else
GUICtrlSetState($AddPESource
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -