Description
This script provides a GUI tool for WAIK that makes building WinPE boot discs a hell of a lot easier.
Source Code
#RequireAdmin
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=..\..\Icons\Programs-Windows.ico
#AutoIt3Wrapper_Compression=4
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#cs ----------------------------------------------------------------------------
AutoIt Version: 3.3.6.1
Author: Josiah Kerley
Script Function:
This is the GUI for WAIK Builder.
#ce ----------------------------------------------------------------------------
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
RunWait("Dism /unmount-Wim /MountDir:Current_WinPE\mount /discard")
#Region ### START Koda GUI section ### Form=s:\storage service\appsupport\scripts\autoit\projects\waik builder\waik.kxf
$WAIK = GUICreate("WAIK", 172, 261, 192, 114)
$btnDrivers = GUICtrlCreateButton("Add Drivers", 8, 16, 155, 25)
GUICtrlSetTip(-1, "Copy and paste driver installers into the folder to have applicable drivers added to the disc.")
$btnExe = GUICtrlCreateButton("Add Executables", 8, 56, 155, 25)
GUICtrlSetTip(-1, "Copy and paste executables (or other files) into the folder to have them added to the disc. All files will be placed in the C:\Windows\ folder of the ISO.")
$btnEdit = GUICtrlCreateButton("Edit StartNet.CMD", 8, 96, 155, 25)
GUICtrlSetTip(-1, "This is the Batch File that initilizes the system (Think autoexec.bat). By default, wpeinit will be added to the first line.")
$btnBuild = GUICtrlCreateButton("Build ISO", 8, 168, 155, 25)
GUICtrlSetTip(-1, "Builds Disc")
$cbxPressAny = GUICtrlCreateCheckbox("Keyed Boot", 48, 136, 81, 17)
GUICtrlSetTip(-1, "Enables the ""Press Any Key Boot"". This allows the disc to be left in the CD-ROM drive without needing to remove it at reboot.")
$btnUnmount = GUICtrlCreateButton("Force Unmount", 8, 224, 155, 25)
GUICtrlSetTip(-1, "If the image asset folder is un-deletable, it is probably because imagex has locked it via a mount. Use this button to force it unlocked.")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $btnDrivers
DirCreate("Drivers")
MsgBox(0,"WAIK Builder","Copy and paste driver installers into the folder to have applicable drivers added to the disc.")
Run("explorer Drivers")
Case $btnExe
DirCreate("EXEs")
MsgBox(0,"WAIK Builder","Copy and paste executables (or other files) into the folder to have them added to the disc. All files will be placed in the C:\Windows\ folder of the ISO.")
Run("explorer EXEs")
Case $btnEdit
MsgBox(0,"WAIK Builder","This is the Batch File that initilizes the system (Think autoexec.bat). By default, wpeinit will be added to the first line.")
if(FileExists("startnet.cmd")) Then
RunWait("notepad startnet.cmd")
Else
WriteStartNet()
RunWait("notepad startnet.cmd")
EndIf
Case $btnBuild
BuildISO()
MsgBox(0,"WAIK Builder","Disc Complete")
CleanUp()
Case $btnUnmount
RunWait("Dism /unmount-Wim /MountDir:Current_WinPE\mount /discard")
RunWait("imagex /unmount Current_WinPE\mount")
MsgBox(0,"WAIK Builder","Unmount Complete")
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd
func WriteStartNet()
Local $file = FileOpen("startnet.cmd", 1)
FileWrite($file, "wpeinit" & @CRLF)
FileClose($file)
EndFunc
Func BuildISO()
$ProjectName = "WinPEBootDisc"
$ProjectName = InputBox("WAIK Builder", "What is the name of your project?", "WinPEBootDisc", "")
MsgBox(0,"WAIK Builder","Go grab some coffee, this could take a while. Expect it to take 10-20 minutes. You'll see a bunch of black boxes pop up, but don't be alarmed. It's just building.",5)
$EnvPath = EnvGet("PATH")
EnvSet("PATH",$EnvPath & ";C:\Program Files\Windows AIK\Tools\PETools\;C:\Program Files\Windows AIK\Tools\PETools\..\AMD64;C:\Program Files\Windows AIK\Tools\PETools\..\x86;C:\Program Files\Windows AIK\Tools\PETools\..\AMD64\Servicing;C:\Program Files\Windows AIK\Tools\PETools\..\x86\Servicing;C:\WinPE\Tools\PETools\;C:\WinPE\Tools\PETools\..\AMD64;C:\WinPE\Tools\PETools\..\x86;C:\WinPE\Tools\PETools\..\AMD64\Servicing;C:\WinPE\Tools\PETools\..\x86\Servicing;")
$EnvPath = EnvGet("PATH")
$ProgDat = "C:\ProgramData\WAIK Tools"
$InstallINI = $ProgDat & "\Install.ini"
$installPath = IniRead($InstallINI,"GeneralInfo","installPath","C:\")
;RunWait($installPath & "\Tools\PETools\copype.cmd x86 Current_WinPE")
RunWait("copype.cmd x86 Current_WinPE")
FileCopy("Current_WinPE\winpe.wim","Current_WinPE\ISO\sources\boot.wim")
RunWait("Dism /Mount-Wim /WimFile:Current_WinPE\ISO\sources\boot.wim /index:1 /MountDir:Current_WinPE\mount")
;RunWait("copy EXEs\* Current_WinPE\mount\Windows")
DirCopy("EXEs","Current_WinPE\mount\Windows\",1)
FileCopy("startnet.cmd","Current_WinPE\mount\Windows\System32\startnet.cmd",1)
If not (GUICtrlRead($cbxPressAny) == 1) Then
FileDelete("Current_WinPE\ISO\boot\bootfix.bin")
EndIf
Sleep(500)
FileDelete("startnet.cmd")
FileInstall("Add Drivers.exe","ED.exe",1)
RunWait("ED.exe")
FileDelete("ED.exe")
RunWait("Dism /unmount-Wim /MountDir:Current_WinPE\mount /Commit")
RunWait("oscdimg -n -bCurrent_WinPE\etfsboot.com Current_WinPE\ISO """ & $ProjectName & ".iso""")
EndFunc
Func CleanUp()
$cleanUp = MsgBox(4,"WAIK Builder","Do you want to clean up files?")
If($cleanUp == "6") Then
DirRemove("Current_WinPE",1)
DirRemove("Drivers",1)
DirRemove("EXEs",1)
EndIf
EndFunc
Screenshots
