⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 winsetupfromusb_0-1-1.au3

📁 U盘装纯净版系统
💻 AU3
📖 第 1 页 / 共 5 页
字号:
#RequireAdmin
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_icon=5_1.ico
#AutoIt3Wrapper_Compression=4
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
;Parted Magic 3.0
;merge filelist arrays and check for duplicates
;ubuntu, knoppix...
;binifix rdummy

#cs ----------------------------------------------------------------------------
 AutoIt Version: 3.2.10.0
 Author:         Ilko
 Version:		 0.1.1
 Credits: jaclaz, cdob, wimb and porear from MSFN forum for their continous help and work on Installing XP from USB
 as well as everyone, who contributed to the project with ideas, requests or feedback.
 
 Thanks to UglyBob, ptrex, SmOke_N, aec and ezzetabi from AutoIt forum for their excellent AutoIt script examples, parts of which were used.
 Thanks to Anton Bassov for his dummydisk.sys driver and help for reverting it's behaviour to rdummy.sys, which makes USB fixed disks to be seen as removabe

The program is released "as is" and is free for redistribution, use or changes as long as original author, credits part and link to the support forum-
http://www.msfn.org/board/Install-XP-from-USB-f157.html 
are clearly mentioned.
Author does not take any responsibility for use or misuse of the program.
#ce ----------------------------------------------------------------------------
;#include <AutoItErrorHandler_UDF.au3>
#include <GUIConstants.au3>
#include <ProgressConstants.au3>
#include <Date.au3>
#include <Array.au3>
#Include <GuiComboBox.au3>
#include <File.au3>
#Include <GuiStatusBar.au3>
#include <String.au3>
Opt("GUIOnEventMode", 1)
Opt("TrayIconHide", 1)
;variables
Global $WinSource="",$SourceVersion,$WinSourceSize=0,$TotalSourceSize=0,$TargetDrive,$VistaSource,$PESource,$GPartedSource, $GPartedSize = 0, $SysLinuxSource, $SysLinuxSize = 0
Global $USBdrives, $VistaSize=0, $PESize=0, $LastGroupUsed, $PrevWinSource="", $NrCpdFiles, $menulst, $TargetSpaceAvail=0, $AMD64=0, $vers, $sp, $GpVers
Global $TempWinSource, $TempPESource, $TempGPSource, $TempVistaSource, $TempSysLinuxSource, $Paused, $targetActive, $logfile, $a, $b, $sync, $dt
If FileExists(@ScriptDir & "\WinSetupFromUSB.log") Then
	RunWait(@ComSpec & " /c makecab.exe " & "WinSetupFromUSB.log" & " log.cab", @ScriptDir, @SW_HIDE)
	$dt = StringReplace(_NowCalc(), "/", "", 0)
	$dt = StringReplace($dt, ":", "", 0)
	$dt = StringReplace($dt, " ", "-", 0)
	FileMove(@ScriptDir & "\log.cab", @ScriptDir & "\backups\" & $dt & "-log.cab", 8)
	FileDelete(@ScriptDir & "\WinSetupFromUSB.log")
EndIf
HotKeySet("{PAUSE}", "TogglePause")
;HotKeySet("{ESC}", "Quit")
;HotKeySet("{F5}", "PopulateUSBComboBox")
Logging("---------------------------------Program started-----------------------------------------------")
;===================================================================================================
;
;        							  Create GUI
;
;===================================================================================================
;=================================================================================================================================
#Region ### START Koda GUI section ### 
$mainwindow = GUICreate("WinSetupFromUSB 0.1.1", 449, 488, 241, 153)
$SourceDir = GUICtrlCreateButton("Browse", 376, 32, 44, 23)
$Source = GUICtrlCreateInput("", 24, 32, 337, 21)
$RefreshUSB = GUICtrlCreateButton("Refresh", 376, 72, 44, 23)
$HP_format = GUICtrlCreateButton("HP format tool", 208, 136, 81, 23)
$PEtoUSB = GUICtrlCreateButton("PEtoUSB", 320, 136, 81, 23)
$RemovableRadio = GUICtrlCreateRadio("Removable", 24, 128, 113, 17)
$FixedRadio = GUICtrlCreateRadio("Fixed", 24, 152, 113, 17)
$ComboBoxTarget = GUICtrlCreateCombo("", 24, 72, 337, 25)
$GO = GUICtrlCreateButton("GO", 256, 416, 89, 33)
$EXIT = GUICtrlCreateButton("EXIT", 360, 416, 65, 33)
$BootINILabel1 = GUICtrlCreateLabel("Windows will be installed in:", 24, 224, 135, 15)
$WinTarget = GUICtrlCreateInput("\WINDOWS", 24, 240, 135, 21)
$WinTargetDisk = GUICtrlCreateInput("0", 32, 280, 25, 21)
$WinTargetPartition = GUICtrlCreateInput("1", 112, 280, 25, 21)
$WinTargetDiskLabel = GUICtrlCreateLabel("Disk Nr:", 24, 264, 42, 15)
$WinTargetPartitionLabel = GUICtrlCreateLabel("Partition Nr:", 96, 264, 59, 15)
$AddPECheck = GUICtrlCreateCheckbox("", 200, 240, 17, 17)
$AddPEBrowse = GUICtrlCreateButton(". . .", 384, 240, 33, 21)
$AddPeSource = GUICtrlCreateInput("", 224, 240, 153, 21)
$AddVistaCheck = GUICtrlCreateCheckbox("", 200, 280, 17, 17)
$AddVistaBrowse = GUICtrlCreateButton(". . .", 384, 280, 33, 21)
$AddVistaSource = GUICtrlCreateInput("", 224, 280, 153, 21)
$AddGPartedCheck = GUICtrlCreateCheckbox("", 200, 320, 17, 17)
$AddGPartedBrowse = GUICtrlCreateButton(". . .", 384, 320, 33, 21)
$AddGPartedSource = GUICtrlCreateInput("", 224, 320, 153, 21)
$AddSysLinuxCheck = GUICtrlCreateCheckbox("", 200, 360, 17, 17)
$AddSysLinuxBrowse = GUICtrlCreateButton(". . .", 384, 360, 33, 21)
$AddSysLinuxSource = GUICtrlCreateInput("", 224, 360, 153, 21)
$LabelFormatTarget = GUICtrlCreateGroup("Format target using", 192, 112, 233, 65)
$WinTargetAdd = GUICtrlCreateInput("\WINDOWS", 24, 320, 135, 21)
$TargetDiskAdd = GUICtrlCreateInput("1", 40, 360, 25, 21)
$TargetPartitionAdd = GUICtrlCreateInput("3", 112, 360, 25, 21)
$WinTargetAddDisk = GUICtrlCreateLabel("Disk Nr:", 32, 344, 42, 15)
$WinTargetAddPart = GUICtrlCreateLabel("Partition Nr:", 96, 344, 59, 15)
$BootINIAddCheck = GUICtrlCreateCheckbox("Additional entry in BOOT.INI", 24, 304, 154, 15)
$BootINIAdjGroup = GUICtrlCreateGroup("BOOT.INI adjustments", 16, 208, 161, 185)
$ForceTargetGroup = GUICtrlCreateGroup("Force Target disk type", 16, 112, 161, 65)
$OptionallyLabel1 = GUICtrlCreateGroup("You may also add:", 192, 208, 233, 185)
$Label2 = GUICtrlCreateLabel("UBCD4Win/BartPE/WinBuilder", 224, 224, 150, 15)
$Label3 = GUICtrlCreateLabel("Vista setup/PE/Recovery ISO", 224, 264, 150, 15)
$Label4 = GUICtrlCreateLabel("GParted 0.3.4-8 to 0.3.9-4", 224, 304, 150, 15)
$Label5 = GUICtrlCreateLabel("SysLinux bootsector/distro", 224, 344, 150, 15)
$ProgressAll = GUICtrlCreateProgress(16, 424, 225, 16, $PBS_SMOOTH)
$BootOnlyCheck = GUICtrlCreateCheckbox("Copy setup boot files only", 24, 184, 145, 17)
$qemu = GUICtrlCreateCheckbox("Test in QEMU, use at own risk", 200, 184, 233, 17)
$Label1 = GUICtrlCreateLabel("Windows 2000/XP/2003 Source", 24, 16, 166, 15)
$Label6 = GUICtrlCreateLabel("USB Disk Selection", 24, 56, 171, 15)
$Group2 = GUICtrlCreateGroup("", 16, 8, 409, 97)
;$FileMenu = GUICtrlCreateMenu("&File")
;$HelpMenu = GUICtrlCreateMenu("&Help")
;$AboutItem = GUICtrlCreateMenuitem ("About",$HelpMenu)
;$ExitItem = GUICtrlCreateMenuitem ("Exit",$FileMenu)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

;=================================================================================================================================
$hStatus = _GUICtrlStatusBar_Create($mainwindow, -1, "", $SBARS_TOOLTIPS)
Global $aParts[5] = [40, 90, 355, 400, -1] ;total width is 445
_GUICtrlStatusBar_SetParts($hStatus, $aParts)
_GUICtrlStatusBar_SetTipText ($hStatus, 0, "Current selection in MB")
_GUICtrlStatusBar_SetTipText ($hStatus, 1, "Total space on target disk")
_GUICtrlStatusBar_SetTipText ($hStatus, 2, "File being copied")
_GUICtrlStatusBar_SetTipText ($hStatus, 3, "Number of files copied")
_GUICtrlStatusBar_SetTipText ($hStatus, 4, "Total number of files to be copied")
GUISetOnEvent($GUI_EVENT_CLOSE, "Quit")
GUICtrlSetState($SourceDir, $GUI_FOCUS) ; the focus is on this button
GUICtrlSetOnEvent($SourceDir, "GetSource")
GUICtrlSetTip($SourceDir, "Select Windows source, where folder I386 can be found", "", 0, 1)
GUICtrlSetTip($Source, "Windows source, where folder I386 can be found", "", 0, 1)
GUICtrlSetOnEvent($RefreshUSB, "PopulateUSBComboBox")
GUICtrlSetTip($RefreshUSB, "Refresh USB disks information" & @CRLF & @CRLF & "Only properly formatted disks with active partition will be displayed!", "", 0, 1)
GUICtrlSetOnEvent($HP_format, "FormatHP")
GUICtrlSetTip($HP_format, "Format USB disk using HP USB storage format tool 2.0.6." & @CRLF & @CRLF & "All partitions on the USB disk will be lost!" _ 
& @CRLF & @CRLF & "If it is USB hard disk you may use Windows format, but make sure you set an active partition" _
& @CRLF & "from disk management!" & @CRLF & "NTFS may greatly improve sluggish performance on some systems or disks.", "", 0, 1)
GUICtrlSetOnEvent($PEtoUSB, "PEtoUSB")
GUICtrlSetTip($PEtoUSB, "Format USB disk using PEtoUSB, use for FAT16 or FAT16x." & @CRLF & "Use for partitions up to 2GB." _ 
& @CRLF & @CRLF & "If it is USB hard disk you may use Windows format, but make sure you set an active partition" _
& @CRLF & "from disk management console!", "", 0, 1)
GUICtrlSetTip($RemovableRadio, "Force selection if for some reason USB disk type was not detected properly" _
& @CRLF & "or you are using filter driver such as Hitachi microdrive filter driver or Dummydisk.sys", "", 0, 1)
GUICtrlSetTip($FixedRadio, "Force selection if for some reason USB disk type was not detected properly" _
& @CRLF & "or you are using filter driver such as Hitachi microdrive filter driver or Dummydisk.sys", "", 0, 1)
GUICtrlSetOnEvent($ComboBoxTarget, "GetComboUSBSelection")
GUICtrlSetTip($ComboBoxTarget, "Only disks with an active partition will be displayed!" & @CRLF & "If your USB disk is not displayed make sure" _
& " it has an active partition and MBR" & @CRLF & " or simply format it with the tools below","", 0, 1)
GUICtrlSetState($GO, $GUI_DISABLE)
GUICtrlSetOnEvent($GO, "Main") 
GUICtrlSetOnEvent($EXIT, "Quit")
GUICtrlSetTip($WinTarget, "Change this if you are going to install Windows to a different folder than \WINDOWS", "", 0, 1)
GUICtrlSetTip($WinTargetDisk, "Disk numeration starts from 0, i.e. your first internal disk is 0", "", 0, 1)
GUICtrlSetTip($WinTargetPartition, "Partition numeration starts from 1, i.e. your first partition is 1", "", 0, 1)
GUICtrlSetOnEvent($AddPECheck, "EnableInputBox")
GUICtrlSetTip($AddPECheck, "Add BartPE/WnBulder/UBCD4Win/WinFLPC/WinPE to the USB disk." & @CRLF & @CRLF _
& "Will copy folders I386 as MININT, PROGRAMS/Program Files, IMAGES, CMDCONS and Setup if found." _
& @CRLF & @CRLF & "If it is UBCD4Win and folder IMAGES exist, only default multiboot options will be added" _
& @CRLF & "Edit UBCD4WIN.LST in partition root to add custom entries.", "", 0, 1)
GUICtrlSetState($AddPEBrowse, $GUI_DISABLE)
GUICtrlSetOnEvent($AddPEBrowse,"GetPESource")
GUICtrlSetTip($AddPEBrowse, "Browse for PE folder." & @CRLF & "Will copy files in root and folders I386 as MININT, PROGRAMS/Program Files, IMAGES and CMDCONS if found." _
& @CRLF & "If it is UBCD4Win and folder IMAGES exist, only default multiboot options will be added." _
& @CRLF & "Edit UBCD4WIN.LST in USB root to add custom entries", "", 0, 1)

GUICtrlSetState($AddPeSource, $GUI_DISABLE)
GUICtrlSetTip($AddVistaCheck, "Add Vista setup/PE/Recovery to the USB disk.", "", 0, 1)
GUICtrlSetOnEvent($AddVistaCheck, "EnableInputBox")
GUICtrlSetState($AddVistaBrowse, $GUI_DISABLE)
GUICtrlSetOnEvent($AddVistaBrowse,"GetVistaSource")
GUICtrlSetState($AddVistaSource, $GUI_DISABLE)
GUICtrlSetOnEvent($AddGPartedCheck, "EnableInputBox")
GUICtrlSetTip($AddGPartedCheck, "Add GParted to the USB disk. Versions 0.3.4-8,0.3.6-7,0.3.7-7 and 0.3.9-4 are supported", "", 0, 1)
GUICtrlSetState($AddGPartedBrowse, $GUI_DISABLE)
GUICtrlSetOnEvent($AddGPartedBrowse,"GetGPartedSource")
GUICtrlSetTip($AddGPartedBrowse, "Click to select where folder LIVE or file GPARTED.DAT can be found." _ 
& @CRLF & "You may extract them either from the ISO or Live USB zip package", "", 0, 1)
GUICtrlSetState($AddGPartedSource, $GUI_DISABLE)
GUICtrlSetOnEvent($AddSysLinuxCheck, "EnableInputBox")
GUICtrlSetTip($AddSysLinuxCheck, "Add SysLinux based Linux distro to the USB disk. Entire contents of your selection will be copied" _
 & @CRLF & "Make sure you don't have existing files/folders with the same names on the USB disk, as script will NOT overwrite them!" & @CRLF _
 & @CRLF & "If source is not selected, then SysLinux bootsector will be made, LDLINUX.SYS copied to root of USB disk," _
& @CRLF &  "and an entry in boot menu added.", "", 0, 1)
GUICtrlSetState($AddSysLinuxBrowse, $GUI_DISABLE)
GUICtrlSetOnEvent($AddSysLinuxBrowse,"GetSysLinuxSource")
GUICtrlSetState($AddSysLinuxSource, $GUI_DISABLE)
GUICtrlSetState($WinTargetAdd, $GUI_DISABLE)
GUICtrlSetTip($TargetDiskAdd, "Disk numeration starts from 0, i.e. your second internal disk is 1", "", 0, 1)
GUICtrlSetState($TargetDiskAdd, $GUI_DISABLE)
GUICtrlSetTip($TargetPartitionAdd, "Partition numeration starts from 1, i.e. your third partition is 3", "", 0, 1)
GUICtrlSetState($TargetPartitionAdd, $GUI_DISABLE)
GUICtrlSetTip($BootINIAddCheck, "Use if you want to have an additional line in BOOT.INI on the USB disk," & @CRLF _
& "so you can launch second part(GUI) of setup from a different disk/partition", "", 0, 1)
GUICtrlSetOnEvent($BootINIAddCheck, "EnableInputBox")
GUICtrlSetTip($BootOnlyCheck, "Use to test boot before copying the main part","", 0, 1)
GUICtrlSetOnEvent($BootOnlyCheck, "BootOnly")
GUICtrlSetTip($qemu, "Use at your own risk, data loss may occur on ANY of your hard disks!!!" & @CRLF & "Do NOT use if you are not sure what you are doing!" _
& @CRLF & @CRLF &"Note, that results may and will differ from those on real hardware.", "", 0, 1)
GUICtrlSetOnEvent($qemu, "CheckGo")
;GUICtrlSetOnEvent($ExitItem, "Quit")
;GUICtrlSetOnEvent($AboutItem ,"About")

GUISetState(@SW_SHOW)
;===================================================================================================
;
;       							    End GUI
;
;===================================================================================================
$logfile = FileOpen(@ScriptDir & "\WinSetupFromUSB.log", 1)
Logging ("WinSetupFromUSB 0.1.1 started")
Logging ("OS " & @OSVersion & "  " & @ProcessorArch & " ServicePack: " & @OSServicePack)
PopulateUSBComboBox()  

Loop()
Func Loop()
While 1
	If GUICtrlRead($source) = "" And $WinSource <> "" Then 
		$WinSource = ""
		$TempWinSource = ""
		CheckSize()
		CheckGo()
	EndIf
	Sleep(1000)
	$a = StringLeft(GUICtrlRead($WinTarget), 9)
	GUICtrlSetData($WinTarget, $a)
	$b = StringLeft(GUICtrlRead($WinTargetAdd), 9)
	GUICtrlSetData($WinTargetAdd, $b)
WEnd
EndFunc ;==>Loop()

; --------------------------------------------------------------------------------------------------
;
;       							    FUNCTIONS
;
; --------------------------------------------------------------------------------------------------
;===================================================================================================
Func Main()
	Local $Copy[5], $FileList, $SourceList[1][3], $txtsetupsif, $i, $unatout, $unattend, $file, $presetup, $ini, $sl, $src, $dest, $msg
	Local $instsyslin = 0, $aArray, $DriversPath, $OEMPreinstall
	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

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -