How do I detect if WinPE(4) has booted from a UEFI or BIOS?


I am looking for a way to reliably detect when I boot into WinPE 4 (powershell) (or WinPE 3 (vbs) as an alternative), have I booted from a UEFI or BIOS System? (without running a third party exe as I am in a restricted environment)

This significantly changes how I would be partitioning a windows deployment as the partitions layout changes and format. (GPT vs. MBR, etc)

I have one working that is an adaptation of this C++ code in powershell v3 but it feels pretty hack-ish :

This seems pretty over the top just to get a simple flag.

Does anyone know if there is there a better way to get this done?


It is no less hacky, in the sense it will still require interop from powershell, but the interop code might be neater if you use (or can call): GetFirmwareType().

This returns a FIRMWARE_TYPE enumeration documented here. I can’t believe given both functions are introduced in Windows 8 and exported by kernel32.dll that Microsoft’s own documentation points you at “using a dummy variable”!

Internally, GetFirmwareType calls NtQuerySystemInformation. I will dig into what it is doing, but I do not think it is necessarily going to be enlightening.

Unfortunately, this only works for PE4 (Windows 8) since these functions were only added then.


How do I detect if WinPE(4) has booted from a UEFI or BIOS? by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply