How to determine that the current OS is WinPE?

Just starting out? Need help? Post your questions and find answers here.
AZJIO
Addict
Addict
Posts: 2225
Joined: Sun May 14, 2017 1:48 am

How to determine that the current OS is WinPE?

Post by AZJIO »

I can guess the methods, but they are not accurate.
1. Get the computer name “Win10PE” and find the abbreviation “PE” in the name. The name depends on the author of WinPE, which means it can be without the abbreviation "PE".
2. Check that drive X:\ and B:\ exist. These disks may exist in a regular OS and, conversely, not exist in WinPE.
3. Check virtual disks using QueryDosDevice, the presence of "\Device\Ramdisk".
BarryG
Addict
Addict
Posts: 4219
Joined: Thu Apr 18, 2019 8:17 am

Re: How to determine that the current OS is WinPE?

Post by BarryG »

From https://stackoverflow.com/questions/631 ... pe-version :

"If you simply need to determine whether you are running WinPE or not, you can check for the presence of the key MiniNT in
HKLM\System\CurrentControlSet\Control or HKLM\System\ControlSet001\Control. If it is present, you are on WinPE 2.x or higher.
For very old versions of Windows/WinPE before 2.0, check the version of %SYSTEMROOT%\SYSTEM32\FACTORY.EXE."

Microsoft's answer -> https://learn.microsoft.com/en-us/windo ... pe-version
hdt888
User
User
Posts: 57
Joined: Sun Jul 07, 2024 8:42 am

Re: How to determine that the current OS is WinPE?

Post by hdt888 »

WinPE often has wmic omitted. just check the existence of this file.
PB 5.x + 6.x + Win10. Feel the ...Pure... Power.
User avatar
ChrisR
Addict
Addict
Posts: 1484
Joined: Sun Jan 08, 2017 10:27 pm
Location: France

Re: How to determine that the current OS is WinPE?

Post by ChrisR »

hmm, checking vmic isn't really a good idea, WinPE-WMI is an Optional Components, available in Windows ADK
and thus present in many WinPEs, such as Win10XPE

If you want to test on a file, you can test if winpeshl.exe exist
But it's better to do it like BarryG wrote, check for the presence of the MiniNT registry key:

Batch example IsWinPE.cmd:

Code: Select all

@Echo Off
Reg.exe Query HKLM\SYSTEM\ControlSet001\Control\MiniNT 1>Nul 2>Nul
If Not ErrorLevel 1 (
	Echo Windows PE
	Exit /B 1
)
Echo Not a Windows PE
Exit /B 0
Post Reply