- Activate BitLocker with manage-bde, PowerShell, or WMI - Wed, Sep 20 2023
- Join Azure Active Directory with Windows 11 - Tue, Sep 12 2023
- Manage enhanced security mode in Microsoft Edge using Group Policy - Fri, Sep 8 2023
Windows PE has always been part of the WAIK, or Windows ADK, but has been a separate download since Windows 10 1809. This gives the impression that one could create an ISO file or a USB stick with the separately downloaded WinPE files alone. But this is actually not the case.
Installing the WinPE package
If you run setup for Windows PE, it installs the files by default under the following path:
%ProgramFiles(x86)%\Windows Kits\10\
Alternatively, you can download the package into a different directory and start the setup from there. This option is particularly useful if you want to run the installation on other computers as well.
If you start the batch files that are used to create a bootable WinPE at this point, they will abort with various error messages. The main reason is the lack of required environment variables.
Adding deployment tools
Therefore, in the next step, you start the ADK Setup and select Deployment Tools for installation.
When this process is complete, open a command prompt and run the batch file DandISetEnv.bat in the Deployment Tools directory (by default under %ProgramFiles(x86)%\Windows Kits\10\Assessment and Deployment Kit).
Now provision the files that are needed for the ISO or the memory stick. This is done by running copype.cmd:
copype amd64 c:\Users\me\WinPE
The first parameter specifies the processor architecture, in this case 64-bit for Intel or AMD. You can also choose x86, arm, and arm64. The second parameter specifies the target directory. However, this must not yet exist; otherwise, the process will fail.
Adding packages to WIM
The boot.wim file can then be found in media\sources below the directory you specified above. If you want to customize Windows PE, for example by integrating language packs (WinPE is in English by default) or additional features, you mount the WIM with DISM. This is done on the command prompt from the directory you specified as the target in copype.cmd, where mount already exists:
dism /Mount-Wim /MountDir:mount /wimfile:media\sources\boot.wim /index:1
The language files can be found by default under the following path:
%ProgramFiles(x86)%\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\<Architecture>\WinPE_OCs\.
These are added as follows:
dism /image:mount /Add-Package /PackagePath:<Path-to-languageFile>\lp.cab
For example, use
dism /image:mount /Set-AllIntl:de-DE
to set the language of the command line, the keyboard layout, and the location to Germany.
If you want to add PowerShell, the same pattern should be applied. However, you have to copy several packages in a given order. Like the language files, they are located under the directory WinPE_OCs:
- WinPE-WMI.cab
- WinPE-WMI_<language-code>.cab
- WinPE-NetFx.cab
- WinPE-NetFx_<language-code>.cab
- WinPE-PowerShell.cab
- WinPE-PowerShell_<language-code>.cab
- WinPE-StorageWMI.cab
WinPE-StorageWMI_<language-code>.cab
To apply the changes to boot.wim, execute the following command:
dism /Unmount-Wim /MountDir:mount /commit
Activating a different keyboard layout online
If customizing boot.wim seems to be too much work because you just want to have a different keyboard layout, you can get one like this after booting WinPE:
wpeutil setkeyboardlayout 0407:00000407

If you leave WinPE with the English language setting, you may still change the keyboard layout online for other languages
This example activates the German keyboard layout. The individual country codes are listed on this page. Finally, you have to call a fresh copy of cmd.exe, because the change has no effect on the current command line.
Creating ISO
The last step is to create the boot media for Windows PE. The following command serves this purpose:
MakeWinPEMedia.cmd /ISO c:\Users\me\WinPE c:\users\me\WinPE.iso
The /ISO switch is obviously used to create a CD/DVD image, followed by the directory that you specified as the target in copype.cmd, and finally the name of the ISO file.
A USB stick is created in the same way, except that instead of the DVD, the UFD switch is required and the destination is simply the letter of the USB drive:
Subscribe to 4sysops newsletter!
MakeWinPEMedia /UFD c:\Users\me\WinPE G:
If you want to suppress the warning before the stick is formatted, you can add the /F switch to the command.
Hi Wolfgang,
I think there is a little mistake when you speak about executing dism command from the directory specified in copype command. The boot.wim path is a bit different if you do it from the root folder, it should be:
Cheers
L
I have noticed another thing. When trying to execute MakeWinPEMedia.cmd, which was for me located at
C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment
folder, I got an error:
'oscdimg' is not recognized as an internal or external command,
operable program or batch file.
So I did a research and opened the MakeWinPEMedia.cmd batch. There was relative path to oscdimg… But I found the oscdimg folder/application under this folder:
C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Deployment Tools\amd64\
Which is totally different, so relative path could not work. After copying MakeWinPEMedia.cmd to the Oscdimg folder, and executing it from this path, everything worked like a charm.
L
Hi Leos,
thanks, you are right! The path to boot.wim is media\sources. I have written it correctly in the text before the command but failed to add it to the parameter.
The paths in the batch files are a mess. I think the safest way is to open a command prompt using the link wich is added by the ADK setup.
Hi!
I was following the steps provided in this article, but I've found this problems:
Now the script is CopyDandI.cmd and when I try to run the first dism part, there is no media/sources/boot.wim file under the folder where it created the WinPE files.
Any ideas?
Hello Vandrey,
there is no such script as CopyDandl.cmd mentioned. You just need to install the two packages (WinPE and WADK), then run DandISetEnv.bat and next step is
This step will create the folders that you are missing. Just modify the path (I just c:\temp\winPE). The dism commands then must be executed from that path.
Let me know if you need further help.
Cheers
Leos,
Sorry but there is…
I'll post some screenshots:
Evidences
OK, the file is present there, but you do not neet to run it (it is not mentioned in the post). Just run the DandISetEnv.bat and then go straight to
That should do it and you should be able to continue with the dism command.
Great! I was not running the DandiSetEnv.bat first, sorry!
Thanks a lot. Great article!
Hi Wolfgang,
question please. I have created WinPE as per this article, however I am now struggling with very few Powershell commands available there. In WinPE I only got like 400 commands while on my W10 I have around 1500. For example, there is nothing related to Network in WinPE Powershell.
Should that be like this?
Thanks, Leos
Hi Leos,
I have additionally added the 2 remaining packages for disk management (WinPE-StorageWMI.cab,
WinPE-StorageWMI_<language-code>.cab). In total I have now 599 cmdlets but none for networking (like Get-NetAdapter).
Cheers, Wolfgang