This tutorial will show you how to manually create a bootable WinPE 5.0 x64 USB drive, able to boot on machines with Legacy BIOS or the newer UEFI. WinPE 5.0 is based on Windows 8.1.
This tutorial is very similar to my previous tutorial, but there are a few small changes to the packages.
I assume you are computer savvy and have at least basic knowledge regarding running commands and batch scripts.
By the way, there's also a much faster way to create a WinPE 5.0 USB drive, for those who have Windows 8.1 or newer installed, using the RecoveryDrive.exe tool (located in %windir%\system32).
We're not going to use this tool in this tutorial, rather get our hands a little dirty and do it all manually.
*All screenshots in this tutorial were captured on Windows 7 SP1 x64 eng, but it is <u>highly recommended</u> to use a newer OS (Win8.1 or Win10).
Let's begin.
1. First we need a PC/laptop with Windows 7 (or higher) installed on it. As I mentioned, Windows 8.1 or newer is recommended (especially when editing of a BCD store is required).
You obviously need a flash drive, 4GB should be enough. A fast USB3.0/USB3.1/USB3.2 flash drive with a size of at least 16GB is recommended for two reasons: Storing multiple WIM files and other helpful apps.
Faster boot-up speed compared to the old USB2.0 drives. Your PC/laptop should have at least a USB3.0 port to utilize the extra speed.
2. Next we need to download a Windows Assessment and Deployment Kit (ADK). We have several options, such as the ADK for Windows 8.1, or one of the ADKs for Windows 10. Whichever you choose, make sure the ADK corresponds to a Retail (RTM) build.
(!)Stay away from Insider Preview builds, as the OS files inside them have a digital signature WITHOUT a timestamp, which will cause boot failures on certain machines with Secure Boot enabled in the UEFI BIOS.
The ADKs are pretty large, around 3GB. Do note that newer builds have the base ADK and the WinPE addons as two separate downloads, so download both.
When installing the ADK, you'll only need to select the options I marked in this screenshot:
3. Now we're going to make your flash drive bootable. Make sure it doesn't contain important files.
From the Start Menu -> All Programs -> Windows Kits -> Windows ADK, open the</span></span><span style="color:#000000;"><span style="font-family:helvetica, sans-serif;"> <strong>Deployment and Imaging Tools Environment</strong></span></span><span style="color:#000000;"><span style="font-family:helvetica, sans-serif;">, and type</span></span><span style="font-size:14px;"><span style="color:#282828;"><span style="font-family:helvetica, sans-serif;">:</span></span></span><br />
<span style="font-size:14px;"><span style="color:#282828;"><span style="font-family:helvetica, sans-serif;"> </span></span><span style="color:#000000;"><span style="font-family:helvetica, sans-serif;">[</span></span><strong><span style="color:#000000;"><span style="font-family:helvetica, sans-serif;">ATTENTION: Replace # with the DISK number of your flash drive as it appears after typing LIST DISK]
[ATTENTION: Replace DRIVE_LETTER with the letter assigned to your USB flash drive after typing 'assign'. You can see it in Windows Explorer]
diskpartlist disk
select disk #
clean
create par primary
select par 1
active
format quick fs=fat32 label=WinPE5
assign
exit
bootsect /nt60 DRIVE_LETTER /mbr
Here's an example screenshot:
4. Go to: [ADK Install DIR]\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\Media
5. Copy the entire Media folder to C:\Temp\PE5 (so now you should have C:\Temp\PE5\Media).
6. Copy [ADK Install DIR]\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\en-us\winpe.wim into: C:\Temp\PE5\Media\Sources (create this new folder).
7. Rename the file you copied, from winpe.wim to boot.wim
(!) Just to be sure we're using a safe Windows build: We can check one of the files, for example, %windir%\system32\boot\winload.efi, located inside the boot.wim. Extract it with 7-Zip, right-click on it > Properties > Digital Signatures tab, and check if there is a date in the Timestamp field. Once we know it is in fact a safe build, delete this extracted file.
8. From the Start Menu > All Programs > Windows Kits > Windows ADK, open the Deployment and Imaging Tools Environment, and type:
cd /d C:\Temp\PE5
9. We now need to create a new folder which will act as a mount point for the WIM file, so type:
md C:\MOUNT
10. To mount the WIM file, type:
DISM /Mount-Wim /WimFile:C:\Temp\PE5\Media\Sources\boot.wim /Index:1 /MountDir:C:\MOUNT
11. We're now going to modify the boot.wim file by inserting some optional components, which can be found here:
[ADK INSTALL DIR]\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs
Copy the WinPE_OCs folder to C:\Temp\PE5 (so now you should have C:\Temp\PE5\WinPE_OCs).
NOTE: To see what each component contains/adds to WinPE, check this MS article.
12. ATTENTION: After adding each component, we must also add its corresponding language file, otherwise the component you add won't work!!
I recommend adding the following components, in the order they appear:
dism /image:C:\MOUNT /add-package /PackagePath:"C:\Temp\PE5\WinPE_OCs\WinPE-WMI.cab"
dism /image:C:\MOUNT /add-package /PackagePath:"C:\Temp\PE5\WinPE_OCs\en-us\WinPE-WMI_en-us.cab"
dism /image:C:\MOUNT /add-package /PackagePath:"C:\Temp\PE5\WinPE_OCs\WinPE-Scripting.cab"
dism /image:C:\MOUNT /add-package /PackagePath:"C:\Temp\PE5\WinPE_OCs\en-us\WinPE-Scripting_en-us.cab"
dism /image:C:\MOUNT /add-package /PackagePath:"C:\Temp\PE5\WinPE_OCs\WinPE-HTA.cab"
dism /image:C:\MOUNT /add-package /PackagePath:"C:\Temp\PE5\WinPE_OCs\en-us\WinPE-HTA_en-us.cab"
dism /image:C:\MOUNT /add-package /PackagePath:"C:\Temp\PE5\WinPE_OCs\WinPE-NetFx.cab"
dism /image:C:\MOUNT /add-package /PackagePath:"C:\Temp\PE5\WinPE_OCs\en-us\WinPE-NetFx_en-us.cab"
dism /image:C:\MOUNT /add-package /PackagePath:"C:\Temp\PE5\WinPE_OCs\WinPE-SecureStartup.cab"
dism /image:C:\MOUNT /add-package /PackagePath:"C:\Temp\PE5\WinPE_OCs\en-us\WinPE-SecureStartup_en-us.cab"
dism /image:C:\MOUNT /add-package /PackagePath:"C:\Temp\PE5\WinPE_OCs\WinPE-PowerShell.cab"
dism /image:C:\MOUNT /add-package /PackagePath:"C:\Temp\PE5\WinPE_OCs\en-us\WinPE-PowerShell_en-us.cab"
dism /image:C:\MOUNT /add-package /PackagePath:"C:\Temp\PE5\WinPE_OCs\WinPE-Dot3Svc.cab"
dism /image:C:\MOUNT /add-package /PackagePath:"C:\Temp\PE5\WinPE_OCs\en-us\WinPE-Dot3Svc_en-us.cab"
dism /image:C:\MOUNT /add-package /PackagePath:"C:\Temp\PE5\WinPE_OCs\WinPE-StorageWMI.cab"
dism /image:C:\MOUNT /add-package /PackagePath:"C:\Temp\PE5\WinPE_OCs\en-us\WinPE-StorageWMI_en-us.cab"
dism /image:C:\MOUNT /add-package /PackagePath:"C:\Temp\PE5\WinPE_OCs\WinPE-EnhancedStorage.cab"
dism /image:C:\MOUNT /add-package /PackagePath:"C:\Temp\PE5\WinPE_OCs\en-us\WinPE-EnhancedStorage_en-us.cab"
dism /image:C:\MOUNT /add-package /PackagePath:"C:\Temp\PE5\WinPE_OCs\WinPE-SecureBootCmdlets.cab"
dism /image:C:\MOUNT /add-package /PackagePath:"C:\Temp\PE5\WinPE_OCs\WinPE-DismCmdlets.cab"
dism /image:C:\MOUNT /add-package /PackagePath:"C:\Temp\PE5\WinPE_OCs\en-us\WinPE-DismCmdlets_en-us.cab"
* The SecureBootCmdlets package doesn't have a language file associated with it.
* You can put this code in a .bat file and run it to add all these packages in one go.
13. Now let's see how to add some drivers to your WinPE5.0. This step is optional, so if you're doing this for the first time, you can skip it.
First, you'll need to extract the driver so that its CAT, SYS and INF files are accessible, i.e. not in ZIP file.
To add a (single) driver, type for example:
dism /image:C:\MOUNT /add-driver /driver:"C:\PathToDriver\drivername.inf"
Preferably, if you have a folder containing several drivers (each in its own folder), you can add them all in one go by typing:
dism /image:C:\MOUNT /add-driver /driver:[PATH TO DRIVERS FOLDER] /Recurse /ForceUnsigned
This will take a while depending on the quantity and size of the drivers.
14. At this point, prior to committing your changes and unmounting the WIM file, you can copy certain portable standalone applications (such as</span></span><span style="color:#000000;"><span style="font-family:helvetica, sans-serif;"> <strong>Process Explorer</strong></span></span><span style="color:#000000;"><span style="font-family:helvetica, sans-serif;">,</span></span><span style="color:#000000;"><span style="font-family:helvetica, sans-serif;"> <strong>Ghost64</strong></span></span><span style="color:#000000;"><span style="font-family:helvetica, sans-serif;">, etc) into <strong>C:\MOUNT</strong> so that they will reside inside the WIM file. However, I discourage you from doing so, as there's a better way, so bare with me.
15. Go into C:\MOUNT\Windows\System32 and open the file StartNet.cmd with Notepad (right-click on it and select Edit).
16. By default, it only contains a single line (wpeinit). Replace its contents with the following, then save the file:
wpeinit
@echo off
for %%p in (a b c d e f g h i j k l m n o p q r s t u v w x y z) do if exist %%p:Qdir set w=%%p
call %w%:Qdir\Q-dir.exe
The code below is based on Microsoft's own documentation, it does pretty much the same as above. I've tried it, and it works just as well, so use one or the other:
wpeinit
@echo off
@color 1F
:: sets bg color to blue, and text to white
wpeutil.exe WaitForRemovableStorage
wpeutil.exe UpdateBootInfo
set PEBootRamdiskSourceDrive=
for /f "tokens=1-3 delims== %%a in ('reg.exe query "HKLM\SYSTEM\CurrentControlSet\Control /v "PEBootRamdiskSourceDrive 2^nul') do (
if %%a.==PEBootRamdiskSourceDrive. @set PEBootRamdiskSourceDrive=%%~dc
)
if Defined PEBootRamdiskSourceDrive (
echo PEBootRamdiskSourceDrive is %PEBootRamdiskSourceDrive%
)
@call %PEBootRamdiskSourceDrive%\QDir\Q-Dir.exe</pre>
<p><span style="font-size:14px;"><span style="color:#000000;"><span style="font-family:helvetica, sans-serif;">17.</span></span><span
ATTENTION: We're now going to commit our changes and unmount the WIM file. Close ALL file explorers or the unmount process will give you an error!!
Then type the following command:
DISM /Unmount-Wim /MountDir:C:\MOUNT /Commit
When this process is finished, the C:\MOUNT folder will be empty.
18. It is advised to optimize the WIM file, so run the command:
DISM.exe /export-image /sourceimagefile:C:\Temp\PE5\Media\Sources\boot.wim /sourceindex:1 /destinationimagefile:C:\Temp\PE5\Media\Sources\boot_optimized.wim
The optimized file should be a little smaller. It is safe to delete the boot.wim file, and then rename the boot_optimized.wim to boot.wim.
19. Now copy the contents of the folder C:\Temp\PE5\Media to your flash drive (To clarify: Copy what's inside the folder, not including the folder itself).
The WinPE5.0 flash drive is now bootable .
20. Grab Q-Dir portable x64 from here, and extract the files to your bootable flash drive. Make sure the folder is named QDir (without the dash) and resides on the root of the drive.
21. Eject the flash drive, and boot from it by selecting it from the BIOS Boot Menu.
The exact key to get to the Boot menu depends on which motherboard you have.
On Dell computers it's usually F12. On Gigabyte motherboards it's also F12.
Other manufacturers use a different key to get to the boot menu. Please check yours.
Once you are in the boot menu, you'll probably see something like this (I'm using a Gigabyte motherboard, and SanDisk flash drive):
You can choose to boot in legacy mode, or in UEFI mode. Both should work just fine.
22. Once it's done loading, QDir should appear and you can pretty much do anything from here on.
Troubleshooting:
Q: I've followed the guide to the letter, but my USB drive is not booting (I selected it as first boot device). What to do?
A: 1. Download BootIce from here (zip file size is only 857KB): https://sites.google...3.2.zip BootIce by Pauly v1.3.3.2
2. Extract and run BOOTICEx64.exe (or BOOTICEx86.exe if you're using a 32bit OS)
3. Follow the steps in the following screenshot:
4. Try to boot again.