Installation and Upgrade WinPE - Create a custom Windows install USB

download.jpg
information   Information
As you all (should) already know, Windows Setup's install.wim file is growing with each new feature upgrade. It's coming close and soon going over the 4 GB size limit of a FAT32 formatted install media. Already today, if you download WIM-based version 20H2 install media as told here in Shawn Brink's tutorial on our sister site Ten Forums, the install.wim file is 4.9 GB (UK English Windows 10 version 20H2).

There’s nothing in the UEFI specifications that prevents booting a computer from an NTFS formatted USB flash drive. In fact, this so-called limitation is entirely artificial, caused by the single fact that manufacturer has not included correct drivers in UEFI. Luckily, most modern computers can boot from a single-partition NTFS formatted USB flash drive, and install Windows 10 from a single partition USB media containing WIM image larger than 4 GB (maximum file size on FAT32 media).

But what to do if the WIM file is over 4 GB, and your computer cannot boot from an NTFS formatted media?

This tutorial will show how to create a USB flash drive containing a FAT32 formatted WinPE partition, and a bigger NTFS formatted Windows Setup partition. When computer is booted from this USB flash drive, the WinPE partition takes care of boot, then runs Windows Setup from setup partition on same USB.




Contents

Use links to jump to any part, browser back button to return to this table



Part One:Create WinPE
Part Two:Edit WinPE boot.wim
Part Three:Make WinPE ISO
Part Four:Partition USB flash drive
Part Five:Create bootable USB install media



Note   Note
Please notice: I have prepared a custom WinPE ISO image for you. You can download it from my OneDrive: WinPEx86.iso. File size is 443 MB. Although it is a 32-bit WinPE, it can be used to boot both 32 and 64-bit computers, and setup either a 32 or 64-bit Windows 10.

Parts One, Two and Three in this tutorial will show how I edited and customized this WinPE image, and are intended to those users who want to learn how to do it by themselves.

Short: if you want to make this easy, download the provided WinPE ISO, and start from Part Four!



Part One

Create WinPE


1.1 Download and install both Windows 10 ADK (Assessment and Deployment Kit), and Windows PE add-on for the ADK:

Download W10 ADK.jpg
(Click screenshot thumbnails to open images enlarged.)

1.2 When installing ADK, notice that if accepting defaults, the download size is about 7 GB. However, for purpose of this tutorial, you will only need the Deployment Tools module. Unselecting everything else, download size is less than 70 MB:

WADK Deployment Tools.jpg

1.3 Open an elevated ADK Deployment and Imaging Tools Environment, a special mode of Command Prompt. You will find it in Start > W > Windows Kits:

Open Deployment Environment.jpg

1.4 The prompt is quite long. Shorten it by jumping to root of the C: drive with command cd \ (#1 in next screenshot)

1.5 Create 64-bit WinPE files with following command (#2 in next screenshot), where folder D:\WPEx64 is the folder where WinPE files will be created. Folder will be created automatically, it does not need to exist:

Code:
copype amd64 D:\WPEx64

Make PE.jpg

For 32-bit WinPE, the command is as follows:

Code:
copype x86 D:\WPEx86



Part Two

Edit WinPE boot.wim


2.1 Depending on which bit architecture you selected, either folder D:\WPEx86 or D:\WPEx64 now contains all files and folders to create a WinPE ISO or USB.

2.2 To edit it, we must mount WinPE boot.wim file for offline servicing. First, create a mount point folder. In this example, I made a folder C:\Mount. Open an elevated PowerShell, and enter following command to mount boot.wim:

Code:
Mount-WindowsImage -ImagePath D:\WPEx64\Media\Sources\boot.wim -Index 1 -Path C:\Mount

Change -ImagePath folder WPEx64 to WPEx32 if working with 32-bit WinPE.

2.3 Folder C:\Mount now contains WinPE image, and we can edit it. First thing I made when editing the provided custom WinPE image, I added PowerShell support. By default, WinPE does not support PowerShell.

To enable PowerShell, copy and paste the following commands to elevated PowerShell:. Notice that you can copy all commands at once, and paste them all to elevated PowerShell, which will then run them one by one:

Code:
Dism /Add-Package /Image:"C:\Mount" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\WinPE-WMI.cab"
Dism /Add-Package /Image:"C:\Mount" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\en-us\WinPE-WMI_en-us.cab"
Dism /Add-Package /Image:"C:\Mount" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\WinPE-NetFX.cab"
Dism /Add-Package /Image:"C:\Mount" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\en-us\WinPE-NetFX_en-us.cab"
Dism /Add-Package /Image:"C:\Mount" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\WinPE-Scripting.cab"
Dism /Add-Package /Image:"C:\Mount" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\en-us\WinPE-Scripting_en-us.cab"
Dism /Add-Package /Image:"C:\Mount" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\WinPE-PowerShell.cab"
Dism /Add-Package /Image:"C:\Mount" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\en-us\WinPE-PowerShell_en-us.cab"
Dism /Add-Package /Image:"C:\Mount" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\WinPE-StorageWMI.cab"
Dism /Add-Package /Image:"C:\Mount" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\en-us\WinPE-StorageWMI_en-us.cab"
Dism /Add-Package /Image:"C:\Mount" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\WinPE-DismCmdlets.cab"
Dism /Add-Package /Image:"C:\Mount" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\en-us\WinPE-DismCmdlets_en-us.cab"

The above commands will add PowerShell to a 64-bit WinPE. If you are creating a 32-bit WinPE, change the folder amd64 at the end of long path, near end of each command to x86. An example using the first of above listed commands:

64-bit WinPE:

Rich (BB code):
Dism /Add-Package /Image:"C:\Mount" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\WinPE-WMI.cab"

32-bit WinPE:

Rich (BB code):
Dism /Add-Package /Image:"C:\Mount" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\x86\WinPE_OCs\WinPE-WMI.cab"

2.4 This custom WinPE requires two scripts, a PowerShell scripts to find out drive letter of the NTFS partition on USB containing setup files and then run Windows Setup, and a batch file to run that PS script.

Opening mount point folder C:\Mount, I created a folder Scripts on its root to store these two scripts:

Scripts folder created.jpg

2.5 First the small PS script. To save to mount point folder requires elevated rights, so we need to open Notepad elevated (run as administrator). Copy and paste the following code to it:

Code:
$SetupVolume = (Get-Volume -FileSystemLabel Setup).DriveLetter
$SetupFile = $SetupVolume + ':\setup.exe'
cmd /c $SetupFile

First line will search the USB for volume (partition) labelled Setup, and set its drive letter in variable $SetupVolume. Second line then creates variable $SetupFile, adding the important :\setup.exe to drive letter found in first line. For instance, if $SetupVolume is F, $SetupFile is F:\setup.exe.

Last line then executes command F:\setup.exe, which starts Windows Setup.

Save the file in folder C:\Mount\Scripts as SetupW10.ps1. In Save As dialog, remember to select Save As Type as All files:

Save as All Files.jpg

2.6 Next, short batch file. Copy and paste following code to an elevated Notepad:

Code:
@echo off
rem
rem Run PowerShell script to start Windows Setup
rem
cls
echo.
echo Starting windows Setup...
powershell -ExecutionPolicy bypass -file "X:\Scripts\SetupW10.ps1"

Only important line in this batch file is the last one. It executes the PS script made in step 2.5.

Save it to folder C:\Mount\Scripts as WinSetup.cmd. Again, as with the PS script, in Save As dialog, remember to select Save As Type as All files.

2.7 Last but not least, we need to edit file C:\Mount\Windows\System32\startnet.cmd. Startnet.cmd functions exactly like autoexec.bat did in Windows XP and older Windows versions, running every command in it automatically when WinPE boots.

By default, startnet.cmd only contains one command, wpeinit, which enables WinPE networking capabilities. We add two other commands to it.

Open startnet.cmd in an elevated Notepad. Copy and paste following code to it:

Code:
wpeinit
powercfg /s 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c
X:\Scripts\WinSetup.cmd

The first line is the default command to initialize networking. In second line, we set a High Performance power plan to speed up Windows installation. In last line, we execute the batch file created in step 2.6.

When computer is booted from WinPE media, the contents of WinPE will be copied to RAM disk X. This is why we can use the path X:\Scripts on last command line, there being no need to find out the drive letter for volume containing the Scripts folder.

2.8 In an elevated PowerShell, enter following command to save changes to WinPE:

Code:
Dismount-WindowsImage -Path C:\Mount -Save



Part Three

Make WinPE ISO


3.1 Open an elevated ADK Deployment and Imaging Tools Environment as told in step 1.3.

3.2 Enter following command to create WinPE ISO:

Code:
MakeWinPEMedia /ISO D:\WPEx64 F:\WinPEx64.iso

Change path D:\WPEx64 to D:\WPEx86 if creating a 32-bit WinPE ISO. Path F:\WinPEx64.iso is the path and name of the ISO file that will be created.


Part Four

Partition USB flash drive


4.1 Plug in an at least 8 GB USB lash drive. Open an elevated Command Prompt, start Windows Disk Partitioning utility with command DISKPART.

Enter command LIST DISK to show all attached disks, find out the disk ID for your USB Flash Drive. In my case now, the USB is DISK 3:

Diskpart list disk.jpg

warning   Warning
Be careful, absolutely sure that you find out correct Disk ID! In following step, the selected disk will be wiped clean, and new partitions will be created. Selecting wrong disk may cause Windows or data disks being formatted, all data lost.

4.2 Still in DISKPART, run following commands one by one. In first command, replace X (disk ID) with actual Disk ID for your USB flash drive:

Code:
select disk X
clean
create partition primary size=1024
format quick fs=fat32 label="Boot"
assign
create partition primary
format quick fs=ntfs label="Setup"
assign

4.3 Quit DISKPART with command EXIT. Your USB flash drive is now correctly partitioned, containing a 1 GB partition Boot, and partition Setup which occupies the rest of the USB:

WinPE USB partitioned.jpg


Part Five

Create bootable USB install media


5.1 Mount the WinPE ISO image as a virtual CD / DVD drive (right click, select Mount). Copy its contents, all files and folders, to partition Boot on USB.

5.2 Mount a Windows 10 ISO image as a virtual CD / DVD drive (right click, select Mount). Copy its contents, all files and folders, to partition Setup on USB.

That's it! You have now a bootable USB flash drive to install Windows, even if the install.wim or install.esd file is bigger than FAT32 size limit 4 GB. In the future, when you nbeed install media for a new Windows version, simply format the Setup partition on USB, and copy contents of new ISO to it.

Kari
 

Attachments

  • USB2.png
    USB2.png
    7.6 KB · Views: 77
Last edited:

Try3

Junior Member
Member
VIP
Local time
11:25 AM
Posts
61
Kari,

Thanks. I'm trying it out now [as an alternative to always having to strip out Home edition from the too-big install.wim].

Para 4.1 should include the DiskPart command List disk before the diagram.

All the best,
Denis
 

My Computer

System One

  • Operating System
    Windows 10 Home x64 Version 20H2 Build 19042.985
    Manufacturer/Model
    Dell Inspiron 7779; HP Pavilion TP01-0026na desktop; Chuwi Hi10 Pro
    Internet Speed
    4G
    Browser
    FF, IE

Try3

Junior Member
Member
VIP
Local time
11:25 AM
Posts
61
Kari,

I have tested the InstallUSB [my KariUSB] on two computers with the same fault on both. I have also retested both with my existing InstallUSB and both behave correctly.

I have double-checked that I followed your procedure correctly - I downloaded your WinPE ISO then worked through parts 4 & 5.

With the KariUSB, the Install now screen lacks the Repair your computer item
KariUSB50.jpg


Both computers show the Repair your computer item correctly when booted from my normal InstallUSB.
InstallUSB-Normal.jpg


Since I believe that the process is under the control of setup.exe at this stage, I have re-copied setup.exe from my good InstallUSB to my KariUSB but the symptom remains.
[I also re-copied install.wim but I thought that was bound to be a waste of time anyway.]

So I think I am stuck with my existing procedure
Create Edition-specific Fat32 InstallUSB - [my post #555] - TenForumsTutorials
which takes more messing about than yours would.

Any ideas?

Denis
 
Last edited:

My Computer

System One

  • Operating System
    Windows 10 Home x64 Version 20H2 Build 19042.985
    Manufacturer/Model
    Dell Inspiron 7779; HP Pavilion TP01-0026na desktop; Chuwi Hi10 Pro
    Internet Speed
    4G
    Browser
    FF, IE

Kari

PhD in Malt Based Liquids
WQ Insider
Member
VIP
Local time
12:25 PM
Posts
57
Location
Finnish expat in Leipzig, Germany
Thread starter
Para 4.1 should include the DiskPart command List disk before the diagram.

Thanks. Step 4.1 edited, and screenshot changed.

I have tested the InstallUSB [my KariUSB] on two computers with the same fault on both. I have also retested both with my existing InstallUSB and both behave correctly.

With the KariUSB, the Install now screen lacks the Repair your computer item.

The USB created in this tutorial cannot be used for repair, it should be used only for clean installs.

WinPE on Windows install image is different than the one created with WADK Deployment Tools (steps 1.1 through 1.5). W10 install media's boot.wim file has two indexes (index 1 and index 2), whereas the "real" WinPE has only one (index 1). When W10 install media boot.wim is executed at boot, it offers also the Repair option. This option is missing from "real" WinPE, which is used in this custom W10 USB install media.

Kari
 

My Computer

System One

  • Operating System
    Windows 10 Insider Dev Channel
    Computer type
    Laptop
    Manufacturer/Model
    HP HP ProBook 470 G5
    CPU
    Intel Core i7-8550U
    Motherboard
    HP 837F KBC Version 02.3D.00
    Memory
    16 GB
    Graphics Card(s)
    Intel(R) UHD Graphics 620 & NVIDIA GeForce 930MX
    Sound Card
    Conexant ISST Audio
    Monitor(s) Displays
    Laptop display (17.1") & Samsung U28E590 (27.7")
    Hard Drives
    128 GB SSD & 1 TB HDD
    Internet Speed
    100 Mbps down, 20 Mbps up
    Browser
    Edge Chromium Dev Channel
    Antivirus
    Windows Defender
    Other Info
    2 * 3 TB USB HDD
    6 GB WD Mirror NAS
    Wireless Logitech MK710 keyboard
    Wireless Logitech MSX mouse

Try3

Junior Member
Member
VIP
Local time
11:25 AM
Posts
61
Kari,

OK. Thanks for explaining.

Denis
 

My Computer

System One

  • Operating System
    Windows 10 Home x64 Version 20H2 Build 19042.985
    Manufacturer/Model
    Dell Inspiron 7779; HP Pavilion TP01-0026na desktop; Chuwi Hi10 Pro
    Internet Speed
    4G
    Browser
    FF, IE

slicendice

Active Member
Member
VIP
Local time
1:25 PM
Posts
84
Location
Finland
You've been busy. Awesome content as usual.

I also love the look of this new site!
 

My Computers

System One System Two

  • Operating System
    Windows 10 Pro (19042.928)
    Computer type
    Laptop
    Manufacturer/Model
    Lenovo Thinkpad A485
    CPU
    Ryzen 7 2700U Pro
    Motherboard
    Lenovo
    Memory
    32GB
    Graphics Card(s)
    iGPU Vega 10
    Sound Card
    Realtek
    Monitor(s) Displays
    14" FHD (built-in) + 14" Lenovo Thinkvision M14t (touch+pen)
    Hard Drives
    512GB Intel m.2 PCIe SSD
    PSU
    65W
    Keyboard
    Thinkpad
    Mouse
    Logitech MX Master 2S
    Internet Speed
    400/100Mbit
    Browser
    Edge (Chromium)
    Antivirus
    Windows Defender
    Other Info
    Swapped out the default Realtek wireless card for Intel AC-9260. Oh boy, what a difference in speed and reliability. Once I upgrade my router to WiFi6, I'll swap to Intel AX200.
  • Operating System
    Windows 10 Pro (19042.928) & Linux Mint 20
    Computer type
    PC/Desktop
    Manufacturer/Model
    Custom
    CPU
    i7-2600k @4.4GHz
    Motherboard
    Asus P8Z68-V PRO/GEN3
    Memory
    16GB 4x4GB 1600MHz CL9
    Graphics card(s)
    MSI GTX970 4GB
    Sound Card
    Soundblaster X-Fi
    Monitor(s) Displays
    32" 10-bit Asus PB328Q
    Screen Resolution
    WQHD 2560x1440
    Hard Drives
    1TB Samsung EVO
    PSU
    750W
    Case
    Fractal Design (something old)
    Cooling
    Noctua
    Mouse
    Logitech MX Master 2S
    Keyboard
    Logitech G710+
    Internet Speed
    400/100Mbit
    Browser
    Edge (Cromium)
    Antivirus
    Windows Defender
    Other Info
    Runs all my games well enough (both Windows and Linux)

Kari

PhD in Malt Based Liquids
WQ Insider
Member
VIP
Local time
12:25 PM
Posts
57
Location
Finnish expat in Leipzig, Germany
Thread starter

My Computer

System One

  • Operating System
    Windows 10 Insider Dev Channel
    Computer type
    Laptop
    Manufacturer/Model
    HP HP ProBook 470 G5
    CPU
    Intel Core i7-8550U
    Motherboard
    HP 837F KBC Version 02.3D.00
    Memory
    16 GB
    Graphics Card(s)
    Intel(R) UHD Graphics 620 & NVIDIA GeForce 930MX
    Sound Card
    Conexant ISST Audio
    Monitor(s) Displays
    Laptop display (17.1") & Samsung U28E590 (27.7")
    Hard Drives
    128 GB SSD & 1 TB HDD
    Internet Speed
    100 Mbps down, 20 Mbps up
    Browser
    Edge Chromium Dev Channel
    Antivirus
    Windows Defender
    Other Info
    2 * 3 TB USB HDD
    6 GB WD Mirror NAS
    Wireless Logitech MK710 keyboard
    Wireless Logitech MSX mouse
Top