Sign in to follow this  
Followers 0
Catdaddy

PE 3.0 Create Wizard

1 post in this topic

“PE 3.0 Create Wizard” is a tool I wrote to help build custom PE boot disks and environments. It requires the following to be installed:

• Windows 7 (32 or 64 bit)

• Microsoft Windows Automated Installation Kit (WAIK)(Latest version)

I wrote and tested this on my work laptop which is running the 64 bit version of Windows 7. It's set to only run from Windows 7 but this can be changed easily to any other platform. The reason being is that this script utilizes DISM.EXE which comes natively with Windows 7. You could just as easily add DISM.EXE from the WAIK to your %PATH% and it would work fine.

Based on the input and choices you make from the menu the program extracts and constructs the file and folder structure of a PE installation disk from files available in the WAIK. It assumes that the WAIK is installed at the default location on your drive. If it cannot find it it will ask you for the location.

Depending on the architecture you choose, it will create a destination folder off the root of your C: drive like so:

C:\WinPE_x86

C:\WinPE_ia64

C:\WinPE_amd64

If you already have a folder with any of these names the program will ask permission to overwrite or cancel. Inside each of these folders is a directory named “ISO”. The contents of this folder is what you will burn to disk or copy to a thumb drive.

It will also create a small file in the ISO folder of the PE extraction named WINPE. This is a plain text file with an INI format that reflects the user chosen settings that the program used to create that version of PE.

Example:

[iD]

Arch=x86

DriveLetter=P

ScratchSpace=128

[Packages]

Fonts=0

HTA=1

LegacySetup=0

MDAC=0

PPPoE=0

Scripting=1

Setup=0

SetupClient=0

SetupServer=0

WMI=1

WDS=1

"0" indicates that this package is not installed; "1" means it is. Possibly this file may help anyone trying to build a custom shell or tool inside PE. I don't know, use your imagination.

I know the coding is quite elementary and could probably be cleaned up by a more experienced programmer, but I have taken a lot from this site and learned a volume of information about scripting in general from all of the great examples posted here and I just wanted to give something back in return. Have fun.

#cs ----------------------------------------------------------------------------

Application Title:              PE 3.0 Create Wizard
Version:                        1.0.2.1
Author:                         Rick Hager

Function:

This program will extract a Windows PE installation that can be used for custom
boot environments, Windows OS installations, system recovery and diagnostics tools.
It works with and requires the installation of the Microsoft WAIK 3.0.
It allows you to add custom packages available from the WAIK such as HTA,
WMI and additional font support.

This version will only run from Windows 7 but can be re-configured to run from
other OS versions as well. It assumes the WAIK is installed at the default
location. If it cannot find it it will ask the user for the folder location.

It can create three different versions of PE by architecture: x86, ia64 and
amd64. It will place the resulting files in a folder off the root of C:\.
The extraction process mirrors the actions of COPYPE.CMD, the script found
inside the WAIK. It uses DISM.EXE to mount the boot.wim file and inject the
chosen packages.

It will also create a small file in the ISO folder of the PE extraction named
WINPE. This is a plain text file with an INI format that reflects the
user chosen settings that the program used to create that version of PE.

Example:

[ID]
Arch=x86
DriveLetter=P
ScratchSpace=128

[Packages]
Fonts=0
HTA=1
LegacySetup=0
MDAC=0
PPPoE=0
Scripting=1
Setup=0
SetupClient=0
SetupServer=0
WMI=1
WDS=1

"0" indicates that this package is not installed; "1" means it is. Possibly
this file may help anyone trying to build a custom shell or tool inside PE.

This program was built on and tested in Windows 7 64 bit utilizing the MS
WAIK and PE 3.0 environments. I cannot guarantee this will work with any
earlier versions.

#ce ----------------------------------------------------------------------------

#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>



Global $WAIKFolder = (@ProgramFilesDir & "\Windows AIK")
Global $SourceFolder = ($WAIKFolder & "\Tools\PETools")
Global $DestFolder
Global $Font
Global $HTA
Global $LegacySetup
Global $MDAC
Global $PPPoE
Global $Scripting
Global $Setup
Global $SetupClient
Global $SetupServer
Global $SRT
Global $WMI
Global $WDS



;Make sure we're running Windows 7
;=================================

If @OSVersion <> "Win_7" Then

    MsgBox(16,"Wrong OS Version","This program can only be ran from Windows 7.")
    Exit

EndIf



;Make sure Microsoft WAIK is installed
;=====================================

If FileExists ($WAIKFolder) = 0 Then

    $iMsgBoxAnswer = MsgBox(20,"Installation Not Found","Could not locate Microsoft WAIK installation. Would you like to browse for its location?")

    Select

        Case $iMsgBoxAnswer = 6
            $SelectFolder = FileSelectFolder("Select Folder Location Of Windows AIK", "" , 2)
            $SourceFolder = ($SelectFolder & "\Tools\PETools")

        Case $iMsgBoxAnswer = 7
            Exit

    EndSelect

EndIf



;Draw GUI
;========

$PEWizard = GUICreate("PE 3.0 Create Wizard", 642, 464, -1, -1)

$Group1 = GUICtrlCreateGroup("CPU Architecture", 8, 16, 305, 105)

$Radio1 = GUICtrlCreateRadio("x86", 24, 40, 169, 17)
    GUICtrlSetState(-1, $GUI_CHECKED)

$Radio2 = GUICtrlCreateRadio("ia64", 24, 64, 169, 17)

$Radio3 = GUICtrlCreateRadio("amd64", 24, 88, 121, 17)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    GUICtrlSetTip(-1, "Choose the CPU architecture of the PC that PE will boot from.")

$Group2 = GUICtrlCreateGroup("RAMDisk Settings", 328, 16, 305, 105)

$Combo1 = GUICtrlCreateCombo("32", 488, 40, 65, 25)
    GUICtrlSetData(-1, "64|128|256|512")

$Label1 = GUICtrlCreateLabel("Scratch Space:", 384, 40, 78, 17)
    GUICtrlSetTip(-1, "This sets the amount of space set aside for any programs in your PE environment that require writing to a temp file.")

$Combo2 = GUICtrlCreateCombo("C", 520, 80, 33, 25)
    GUICtrlSetData(-1, "D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z")

$Label2 = GUICtrlCreateLabel("PE Drive Letter:", 384, 80, 79, 17)
    GUICtrlSetTip(-1, "This is the drive letter that the PE environment (Boot.wim) will be assigned to.")
    GUICtrlCreateGroup("", -99, -99, 1, 1)

$Group3 = GUICtrlCreateGroup("Packages", 8, 136, 625, 265)

$Checkbox1 = GUICtrlCreateCheckbox("Fonts - Additional font support.", 24, 161, 177, 25)
    GUICtrlSetTip(-1, "Additional font support for the following languages: ja-JP, ko-KR, zh-CN, zh-HK, and zh-TW.")

$Checkbox2 = GUICtrlCreateCheckbox("HTA - HTML Application support.", 24, 201, 185, 25)
    GUICtrlSetTip(-1, "Enables the creation of GUI applications using the Internet Explorer script engine and HTML services.")

$Checkbox3 = GUICtrlCreateCheckbox("Legacy Setup - The Media Setup feature package.", 24, 241, 265, 25)
    GUICtrlSetTip(-1, "All Setup files from the \Sources folder on the Windows media. Add this package when servicing Setup or the \Sources folder on the Windows media. Must be added with the Setup feature package. To add a new Boot.wim to the media, add either child package in addition to the Setup and Media packages. This package is required to support Windows Server® 2008 R2 installation.")

$Checkbox4 = GUICtrlCreateCheckbox("MDAC - Microsoft Data Access Component support.", 24, 281, 273, 17)
    GUICtrlSetTip(-1, "Enables queries to SQL servers with Active Directory Objects (ADO). Example usage: building a dynamic Unattend from unique system information.")

$Checkbox5 = GUICtrlCreateCheckbox("PPPoE - Enables Point-to-Point Protocol over Ethernet support.", 24, 321, 321, 17)
    GUICtrlSetTip(-1, "Create, connect, disconnect and delete PPPoE connections from Windows PE.")

$Checkbox6 = GUICtrlCreateCheckbox("Scripting - Windows Script Host (WSH) support.", 24, 361, 249, 17)
    GUICtrlSetTip(-1, "Enables batch file processing using WSH script objects.")

$Checkbox7 = GUICtrlCreateCheckbox("Setup - The Setup feature package (parent).", 352, 161, 233, 17)
    GUICtrlSetTip(-1, "All Setup files from the \Sources folder common to Client and Server.")

$Checkbox8 = GUICtrlCreateCheckbox("Setup Client - Client Setup feature package (child).", 352, 201, 257, 17)
    GUICtrlSetTip(-1, "The Client branding files for Setup. Must be added after the Setup feature package.")

$Checkbox9 = GUICtrlCreateCheckbox("Setup Server - Server Setup feature package (child).", 352, 241, 265, 17)
    GUICtrlSetTip(-1, "The Server branding files for Setup. Must be added after the Setup feature package.")

$Checkbox10 = GUICtrlCreateCheckbox("WMI - Windows Management Instrumentation.", 352, 281, 265, 17)
    GUICtrlSetTip(-1, "A subset of the WMI providers that enables minimal system diagnostics.")

$Checkbox11 = GUICtrlCreateCheckbox("WDS Tools - Windows Deployment Services tools.", 352, 321, 265, 17)
    GUICtrlSetTip(-1, "Includes APIs to enable a multicast scenario with a custom Windows Deployment Services client and Image Capture utility.")
    GUICtrlCreateGroup("", -99, -99, 1, 1)

$Button1 = GUICtrlCreateButton("Create", 536, 416, 97, 33, $WS_GROUP)

$Progress1 = GUICtrlCreateProgress(16, 424, 425, 17)

$Label3 = GUICtrlCreateLabel("", 464, 424, 53, 17)
    GUISetState(@SW_SHOW)





;Main loop
;=========

While 1

    $nMsg = GUIGetMsg()

    Switch $nMsg

    Case $GUI_EVENT_CLOSE
            Exit

    Case $Checkbox3
        If GUICtrlRead ($Checkbox3) = 1 Then
            GUICtrlSetState ($Checkbox7, $GUI_CHECKED)
        EndIf

    Case $Checkbox8
        If GUICtrlRead ($Checkbox8) = 1 Then
            GUICtrlSetState ($Checkbox7, $GUI_CHECKED)
        EndIf

    Case $Checkbox9
        If GUICtrlRead ($Checkbox9) = 1 Then
            GUICtrlSetState ($Checkbox7, $GUI_CHECKED)
        EndIf

    Case $Button1
        _Create()

    EndSwitch

WEnd










Func _Create()

    GUICtrlSetData ($Label3, "Working...")

    If GUICtrlRead ($Radio1) = 1 Then $Arch = "x86"
    If GUICtrlRead ($Radio2) = 1 Then $Arch = "ia64"
    If GUICtrlRead ($Radio3) = 1 Then $Arch = "amd64"
    If GUICtrlRead ($Checkbox1) = 1 Then $Font = 1
    If GUICtrlRead ($Checkbox2) = 1 Then $HTA = 1
    If GUICtrlRead ($Checkbox3) = 1 Then $LegacySetup = 1
    If GUICtrlRead ($Checkbox4) = 1 Then $MDAC = 1
    If GUICtrlRead ($Checkbox5) = 1 Then $PPPoE = 1
    If GUICtrlRead ($Checkbox6) = 1 Then $Scripting = 1
    If GUICtrlRead ($Checkbox7) = 1 Then $Setup = 1
    If GUICtrlRead ($Checkbox8) = 1 Then $SetupClient = 1
    If GUICtrlRead ($Checkbox9) = 1 Then $SetupServer = 1
    If GUICtrlRead ($Checkbox10) = 1 Then $WMI = 1
    If GUICtrlRead ($Checkbox11) = 1 Then $WDS = 1
    $Scratch = GUICtrlRead ($Combo1)
    $DriveLetter = GUICtrlRead ($Combo2)
    $DestFolder = ("C:\WinPE_" & $Arch)

    If DirGetSize ($DestFolder) = -1 Then DirCreate ($DestFolder)
    If DirGetSize ($DestFolder) > 0 Then
        $iMsgBoxAnswer = MsgBox(52,"Folder Already Exists","PE Wizard is attempting to create the following directory:" & @CRLF & @CRLF & $DestFolder & @CRLF & @CRLF & "It appears to already exist and contains data. Is it OK to overwrite?" & @CRLF, 0, $PEWizard)
            Select
                Case $iMsgBoxAnswer = 6
                    DirRemove ($DestFolder, 1)
                    DirCreate ($DestFolder)
                Case $iMsgBoxAnswer = 7
                    Return
            EndSelect
    EndIf



;Extract chosen version of PE to $DestFolder
;===========================================

    If DirCreate ($DestFolder & "\ISO") = 0 Then _DirCreateError()

    If DirCreate ($DestFolder & "\mount") = 0 Then _DirCreateError()

    If FileExists ($SourceFolder & "\" & $Arch & "\bootmgr") = 1 Then
        $Stat = FileCopy ($SourceFolder & "\" & $Arch & "\bootmgr", $DestFolder & "\ISO\bootmgr")
        If $Stat = 0 Then _FileCopyError()
    EndIf

    If FileExists ($SourceFolder & "\" & $Arch & "\bootmgr.efi") = 1 Then
        $Stat = FileCopy ($SourceFolder & "\" & $Arch & "\bootmgr.efi", $DestFolder & "\ISO\bootmgr.efi")
        If $Stat = 0 Then _FileCopyError()
    EndIf

    If FileExists ($SourceFolder & "\" & $Arch & "\boot\etfsboot.com") = 1 Then
        $Stat = FileCopy ($SourceFolder & "\" & $Arch & "\boot\etfsboot.com", $DestFolder & "\etfsboot.com")
        If $Stat = 0 Then _FileCopyError()
    EndIf

    If FileExists ($SourceFolder & "\" & $Arch & "\boot\efisys.bin") = 1 Then
        $Stat = FileCopy ($SourceFolder & "\" & $Arch & "\boot\efisys.bin", $DestFolder & "\efisys.bin")
        If $Stat = 0 Then _FileCopyError()
    EndIf

    If FileExists ($SourceFolder & "\" & $Arch & "\boot\efisys_noprompt.bin") = 1 Then
        $Stat = FileCopy ($SourceFolder & "\" & $Arch & "\boot\efisys_noprompt.bin", $DestFolder & "\efisys_noprompt.bin")
        If $Stat = 0 Then _FileCopyError()
    EndIf

    If FileExists ($SourceFolder & "\" & $Arch & "\boot") = 1 Then
        $Stat = DirCopy ($SourceFolder & "\" & $Arch & "\boot", $DestFolder & "\ISO\boot",1)
        If $Stat = 0 Then _FileCopyError()
    EndIf

    If FileExists ($SourceFolder & "\" & $Arch & "\EFI") = 1 Then
        $Stat = DirCopy ($SourceFolder & "\" & $Arch & "\EFI", $DestFolder & "\ISO\EFI",1)
        If $Stat = 0 Then _FileCopyError()
    EndIf

    If DirCreate ($DestFolder & "\ISO\sources") = 0 Then _DirCreateError()

    $Stat = FileCopy ($SourceFolder & "\" & $Arch & "\winpe.wim", $DestFolder & "\winpe.wim")
    If $Stat = 0 Then _FileCopyError()

    GUICtrlSetData ($Progress1, 20)



;Mount WinPE.wim so we can add packages and settings
;===================================================

    $Stat = RunWait ("DISM.exe /Mount-WIM /WimFile:" & $DestFolder & "\winpe.wim /index:1 /MountDir:" & $DestFolder & "\mount", "", @SW_HIDE); Mount winpe.wim
    If $Stat = 0 And @Error Then _DISMError()
    GUICtrlSetData ($Progress1, 25)



;Set scratch space
;=================

    $Stat = RunWait ("DISM.exe /image:" & $DestFolder & "\mount /Set-ScratchSpace:" & $Scratch, "", @SW_HIDE)
    If $Stat = 0 And @Error Then _DISMError()

    GUICtrlSetData ($Progress1, 30)



;Set target path (drive letter)
;==============================

    $Stat = RunWait ("DISM.exe /image:" & $DestFolder & "\mount /Set-TargetPath:" & $DriveLetter & ":\", "", @SW_HIDE)
    If $Stat = 0 And @Error Then _DISMError()

    GUICtrlSetData ($Progress1, 35)



;Begin package installations
;===========================

    $PackageFolder = ($SourceFolder & "\" & $Arch & "\WinPE_FPs")

    If $Font = 1 Then;<===  Font packages

        $Stat = RunWait ("DISM.exe /image:" & $DestFolder & "\mount /Add-Package /PackagePath:" & $PackageFolder & "\en-us\lp_en-us.cab", "", @SW_HIDE)
        If $Stat = 0 And @Error Then _DISMError()

        $Stat = RunWait ("DISM.exe /image:" & $DestFolder & "\mount /Add-Package /PackagePath:" & $PackageFolder & "\winpe-fontsupport-ja-jp.cab", "", @SW_HIDE)
        If $Stat = 0 And @Error Then _DISMError()

        $Stat = RunWait ("DISM.exe /image:" & $DestFolder & "\mount /Add-Package /PackagePath:" & $PackageFolder & "\winpe-fontsupport-ko-kr.cab", "", @SW_HIDE)
        If $Stat = 0 And @Error Then _DISMError()

        $Stat = RunWait ("DISM.exe /image:" & $DestFolder & "\mount /Add-Package /PackagePath:" & $PackageFolder & "\winpe-fontsupport-zh-cn.cab", "", @SW_HIDE)
        If $Stat = 0 And @Error Then _DISMError()

        $Stat = RunWait ("DISM.exe /image:" & $DestFolder & "\mount /Add-Package /PackagePath:" & $PackageFolder & "\winpe-fontsupport-zh-hk.cab", "", @SW_HIDE)
        If $Stat = 0 And @Error Then _DISMError()

        $Stat = RunWait ("DISM.exe /image:" & $DestFolder & "\mount /Add-Package /PackagePath:" & $PackageFolder & "\winpe-fontsupport-zh-tw.cab", "", @SW_HIDE)
        If $Stat = 0 And @Error Then _DISMError()

        GUICtrlSetData ($Progress1, 40)

    EndIf





    If $HTA = 1 Then;<=== HTA package

        $Stat = RunWait ("DISM.exe /image:" & $DestFolder & "\mount /Add-Package /PackagePath:" & $PackageFolder & "\en-us\winpe-hta_en-us.cab", "", @SW_HIDE)
        If $Stat = 0 And @Error Then _DISMError()

        $Stat = RunWait ("DISM.exe /image:" & $DestFolder & "\mount /Add-Package /PackagePath:" & $PackageFolder & "\winpe-hta.cab", "", @SW_HIDE)
        If $Stat = 0 And @Error Then _DISMError()

        GUICtrlSetData ($Progress1, 45)

    EndIf





    If $LegacySetup = 1 Then;<=== Legacy Setup package

        $Stat = RunWait ("DISM.exe /image:" & $DestFolder & "\mount /Add-Package /PackagePath:" & $PackageFolder & "\en-us\winpe-legacysetup_en-us.cab", "", @SW_HIDE)
        If $Stat = 0 And @Error Then _DISMError()

        $Stat = RunWait ("DISM.exe /image:" & $DestFolder & "\mount /Add-Package /PackagePath:" & $PackageFolder & "\winpe-legacysetup.cab", "", @SW_HIDE)
        If $Stat = 0 And @Error Then _DISMError()

        GUICtrlSetData ($Progress1, 50)

    EndIf





    If $MDAC = 1 Then;<=== MDAC package

        $Stat = RunWait ("DISM.exe /image:" & $DestFolder & "\mount /Add-Package /PackagePath:" & $PackageFolder & "\en-us\winpe-mdac_en-us.cab", "", @SW_HIDE)
        If $Stat = 0 And @Error Then _DISMError()

        $Stat = RunWait ("DISM.exe /image:" & $DestFolder & "\mount /Add-Package /PackagePath:" & $PackageFolder & "\winpe-mdac.cab", "", @SW_HIDE)
        If $Stat = 0 And @Error Then _DISMError()

        GUICtrlSetData ($Progress1, 55)

    EndIf





    If $PPPoE = 1 Then;<=== PPPoE package

        $Stat = RunWait ("DISM.exe /image:" & $DestFolder & "\mount /Add-Package /PackagePath:" & $PackageFolder & "\en-us\winpe-PPPOE_en-us.cab", "", @SW_HIDE)
        If $Stat = 0 And @Error Then _DISMError()

        $Stat = RunWait ("DISM.exe /image:" & $DestFolder & "\mount /Add-Package /PackagePath:" & $PackageFolder & "\winpe-pppoe.cab", "", @SW_HIDE)
        If $Stat = 0 And @Error Then _DISMError()

        GUICtrlSetData ($Progress1, 60)

    EndIf





    If $Scripting = 1 Then;<=== Scripting package

        $Stat = RunWait ("DISM.exe /image:" & $DestFolder & "\mount /Add-Package /PackagePath:" & $PackageFolder & "\en-us\winpe-scripting_en-us.cab", "", @SW_HIDE)
        If $Stat = 0 And @Error Then _DISMError()

        $Stat = RunWait ("DISM.exe /image:" & $DestFolder & "\mount /Add-Package /PackagePath:" & $PackageFolder & "\winpe-scripting.cab", "", @SW_HIDE)
        If $Stat = 0 And @Error Then _DISMError()

        GUICtrlSetData ($Progress1, 65)

    EndIf





    If $Setup = 1 Then;<=== Setup package

        $Stat = RunWait ("DISM.exe /image:" & $DestFolder & "\mount /Add-Package /PackagePath:" & $PackageFolder & "\en-us\winpe-setup_en-us.cab", "", @SW_HIDE)
        If $Stat = 0 And @Error Then _DISMError()

        $Stat = RunWait ("DISM.exe /image:" & $DestFolder & "\mount /Add-Package /PackagePath:" & $PackageFolder & "\winpe-setup.cab", "", @SW_HIDE)
        If $Stat = 0 And @Error Then _DISMError()

        GUICtrlSetData ($Progress1, 70)

    EndIf





    If $SetupClient = 1 Then;<=== SetupClient package

        $Stat = RunWait ("DISM.exe /image:" & $DestFolder & "\mount /Add-Package /PackagePath:" & $PackageFolder & "\en-us\winpe-setup-client_en-us.cab", "", @SW_HIDE)
        If $Stat = 0 And @Error Then _DISMError()

        $Stat = RunWait ("DISM.exe /image:" & $DestFolder & "\mount /Add-Package /PackagePath:" & $PackageFolder & "\winpe-setup-client.cab", "", @SW_HIDE)
        If $Stat = 0 And @Error Then _DISMError()

        GUICtrlSetData ($Progress1, 75)

    EndIf





    If $SetupServer = 1 Then;<=== SetupServer package

        $Stat = RunWait ("DISM.exe /image:" & $DestFolder & "\mount /Add-Package /PackagePath:" & $PackageFolder & "\en-us\winpe-setup-server_en-us.cab", "", @SW_HIDE)
        If $Stat = 0 And @Error Then _DISMError()

        $Stat = RunWait ("DISM.exe /image:" & $DestFolder & "\mount /Add-Package /PackagePath:" & $PackageFolder & "\winpe-setup-server.cab", "", @SW_HIDE)
        If $Stat = 0 And @Error Then _DISMError()

        GUICtrlSetData ($Progress1, 80)

    EndIf





    If $WMI = 1 Then;<=== WMI package

        $Stat = RunWait ("DISM.exe /image:" & $DestFolder & "\mount /Add-Package /PackagePath:" & $PackageFolder & "\en-us\winpe-wmi_en-us.cab", "", @SW_HIDE)
        If $Stat = 0 And @Error Then _DISMError()

        $Stat = RunWait ("DISM.exe /image:" & $DestFolder & "\mount /Add-Package /PackagePath:" & $PackageFolder & "\winpe-wmi.cab", "", @SW_HIDE)
        If $Stat = 0 And @Error Then _DISMError()

        GUICtrlSetData ($Progress1, 85)

    EndIf





    If $WDS = 1 Then;<=== WDS package

        $Stat = RunWait ("DISM.exe /image:" & $DestFolder & "\mount /Add-Package /PackagePath:" & $PackageFolder & "\en-us\winpe-wds-tools_en-us.cab", "", @SW_HIDE)
        If $Stat = 0 And @Error Then _DISMError()

        $Stat = RunWait ("DISM.exe /image:" & $DestFolder & "\mount /Add-Package /PackagePath:" & $PackageFolder & "\winpe-wds-tools.cab", "", @SW_HIDE)
        If $Stat = 0 And @Error Then _DISMError()

        GUICtrlSetData ($Progress1, 90)

    EndIf





;Record ID settings in WinPE INI file
;====================================

    IniWrite ($DestFolder & "\ISO\winpe", "ID", "Arch", $Arch)
    IniWrite ($DestFolder & "\ISO\winpe", "ID", "DriveLetter", $DriveLetter)
    IniWrite ($DestFolder & "\ISO\winpe", "ID", "ScratchSpace", $Scratch)

    $INIFile = FileOpen ($DestFolder & "\ISO\WinPE", 1)
    FileWriteLine($INIFile, @CRLF)
    FileClose ($INIFile)

    If $Font = 1 Then
        IniWrite ($DestFolder & "\ISO\winpe", "Packages", "Fonts", "1")
    Else
        IniWrite ($DestFolder & "\ISO\winpe", "Packages", "Fonts", "0")
    EndIf



    If $HTA = 1 Then
        IniWrite ($DestFolder & "\ISO\winpe", "Packages", "HTA", "1")
    Else
        IniWrite ($DestFolder & "\ISO\winpe", "Packages", "HTA", "0")
    EndIf



    If $LegacySetup = 1 Then
        IniWrite ($DestFolder & "\ISO\winpe", "Packages", "LegacySetup", "1")
    Else
        IniWrite ($DestFolder & "\ISO\winpe", "Packages", "LegacySetup", "0")
    EndIf



    If $MDAC = 1 Then
        IniWrite ($DestFolder & "\ISO\winpe", "Packages", "MDAC", "1")
    Else
        IniWrite ($DestFolder & "\ISO\winpe", "Packages", "MDAC", "0")
    EndIf



    If $PPPoE = 1 Then
        IniWrite ($DestFolder & "\ISO\winpe", "Packages", "PPPoE", "1")
    Else
        IniWrite ($DestFolder & "\ISO\winpe", "Packages", "PPPoE", "0")
    EndIf



    If $Scripting = 1 Then
        IniWrite ($DestFolder & "\ISO\winpe", "Packages", "Scripting", "1")
    Else
        IniWrite ($DestFolder & "\ISO\winpe", "Packages", "Scripting", "0")
    EndIf



    If $Setup = 1 Then
        IniWrite ($DestFolder & "\ISO\winpe", "Packages", "Setup", "1")
    Else
        IniWrite ($DestFolder & "\ISO\winpe", "Packages", "Setup", "0")
    EndIf



    If $SetupClient = 1 Then
        IniWrite ($DestFolder & "\ISO\winpe", "Packages", "SetupClient", "1")
    Else
        IniWrite ($DestFolder & "\ISO\winpe", "Packages", "SetupClient", "0")
    EndIf



    If $SetupServer = 1 Then
        IniWrite ($DestFolder & "\ISO\winpe", "Packages", "SetupServer", "1")
    Else
        IniWrite ($DestFolder & "\ISO\winpe", "Packages", "SetupServer", "0")
    EndIf



    If $WMI = 1 Then
        IniWrite ($DestFolder & "\ISO\winpe", "Packages", "WMI", "1")
    Else
        IniWrite ($DestFolder & "\ISO\winpe", "Packages", "WMI", "0")
    EndIf



    If $WDS = 1 Then
        IniWrite ($DestFolder & "\ISO\winpe", "Packages", "WDS", "1")
    Else
        IniWrite ($DestFolder & "\ISO\winpe", "Packages", "WDS", "0")
    EndIf

    GUICtrlSetData ($Progress1, 95)



    $Stat = RunWait ("DISM.exe /Unmount-WIM /MountDir:" & $DestFolder & "\mount /Commit", "", @SW_HIDE); Unmount and commit changes
    If $Stat = 0 And @Error Then _DISMError()

    $Stat = FileCopy ($SourceFolder & "\" & $Arch & "\winpe.wim", $DestFolder & "\ISO\sources\boot.wim");<=== This should be the last thing you do after unmounting the WIM
    If $Stat = 0 Then _FileCopyError()

    GUICtrlSetData ($Progress1, 100)

    GUICtrlSetData ($Label3, "Done.")

    MsgBox(64,"Success","Your PE environment was successfully built.", 0, $PEWizard)

    GUICtrlSetData ($Progress1, 0)

    GUICtrlSetData ($Label3, "")

EndFunc





Func _DirCreateError()
    MsgBox(16,"Unable To Create Folder","There was an error in the folder creation process." & @CRLF & "Template creation is incomplete.",0, $PEWizard)
    Exit
EndFunc





Func _FileCopyError()
    MsgBox(16,"Unable To Copy File","There was an error in the file copy process." & @CRLF & "Template creation is incomplete.",0, $PEWizard)
    Exit
EndFunc





Func _DISMError()
    MsgBox(16,"DISM Error","DISM returned an error and was unable to complete any changes specified to the boot.wim. Template creation is incomplete.",0, $PEWizard)
    RunWait ("DISM.exe /Unmount-WIM /MountDir:" & $DestFolder & "\mount /Discard", "", @SW_HIDE)
    Exit
EndFunc

Share this post


Link to post
Share on other sites



Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0