Share via


How to use WMI to query to distinguish legacy and UEFI mode Windows?

Question

Thursday, April 28, 2011 5:59 PM | 1 vote

How to use WMI to query to distinguish legacy and UEFI mode Windows?

All replies (13)

Monday, May 2, 2011 5:25 PM | 1 vote

Hello,

Maybe I didn't make my question clear. My motherboard BIOS is UEFI BIOS but it supports Legacy Mode.

I can install UEFI Mode Win2K8 R2 and x64 Win7, and I can isntall regular Legacy Mode Windows also.

i want to know how to use WMI to query to distinguish Windows installed in Legacy and UEFI mode?


Tuesday, August 2, 2011 1:37 PM | 1 vote

Superman,

Did you ever figure this out?  I have a need to do the same thing.

 

 


Wednesday, September 21, 2011 7:39 PM | 2 votes

I don't have an answer through WMI, but I did write a utility I could use in WinPE to see if the system executing the binary is UEFI or not.

Binary:

http://xcat.svn.sourceforge.net/svnroot/xcat/xcat-core/trunk/xCAT-server/share/xcat/netboot/windows/detectefi.exe

Source:

http://xcat.svn.sourceforge.net/svnroot/xcat/xcat-core/trunk/xCAT-server/share/xcat/netboot/windows/detectefi.cpp

I know I came looking here for *any* way and assumed WMI was the most likely candidate in a WinPE environment, but this is what I came up with.


Monday, May 7, 2012 3:51 PM | 2 votes

Thanks for the UEFI file.
now, if you wish to use it from Microsoft Deployment Toolkit 2010 check out this link:
http://blogs.microsoft.co.il/blogs/agile/archive/2012/05/06/uefidetectmdt2010.aspx

enjoy :)

Tamir Levy


Monday, December 2, 2013 9:10 PM | 1 vote

Can you recompile detectEFI.exe to work on 32bit systems?  We still using WinPE4_32bit to deploy our OS since many of our systems are still Windows 7 32bit.  It might only be useful for a few years while we transition, but it is most useful compiled for 32bit.


Saturday, March 22, 2014 7:01 PM | 1 vote

Can you recompile detectEFI.exe to work on 32bit systems?  We still using WinPE4_32bit to deploy our OS since many of our systems are still Windows 7 32bit.  It might only be useful for a few years while we transition, but it is most useful compiled for 32bit.

That wouldn't be useful. Microsoft doesn't ship any 32-bit environments that can boot from EFI. If you're running a 32-bit environment, you definitely did NOT boot from EFI.


Tuesday, July 29, 2014 9:38 PM | 1 vote

This is not true. Microsoft supports 32-bit UEFI for 32-bit (x86) tablet devices. This support was added in Windows 8.

I get a 403 when trying to access the detectEFI.exe source. I'd like to see the source as well.


Thursday, July 16, 2015 2:55 AM | 1 vote

I also needed the x86 version of this so i went ahead and compiled it, i figured someone else could use them.

x64

x86

jjj4242, if you want me to remove links please let me know.


Wednesday, July 29, 2015 12:54 PM | 2 votes

This is not true. Microsoft supports 32-bit UEFI for 32-bit (x86) tablet devices. This support was added in Windows 8.

I get a 403 when trying to access the detectEFI.exe source. I'd like to see the source as well.

https://github.com/xcat2/xcat-core/blob/master/xCAT-server/share/xcat/netboot/windows/detectefi.cpp

/* Compile this with cl.exe from MS SDK, e.g. 'cl efidetect.cpp', that is all. */
/* IBM(c) 2011 EPL license http://www.eclipse.org/legal/epl-v10.html */

#include <windows.h>
#include <stdio.h>


int main(int argc, char* argv[])
{
    GetFirmwareEnvironmentVariableA("","{00000000-0000-0000-0000-000000000000}",NULL,0);
    if (GetLastError() == ERROR_INVALID_FUNCTION) { // This.. is.. LEGACY BIOOOOOOOOS....
        printf("Legacy");
        return 1;
    } else {
        printf("UEFI");
        return 0;
    }
    return 0;
}

Tuesday, February 2, 2016 2:15 PM | 1 vote

i Martin,

Can you download detectUefi.exe ?

Because i get a 403 when trying to access source.

Thank you

Michael


Tuesday, February 2, 2016 2:41 PM | 1 vote

I moved around files in my Dropbox, links below should work.

x86

x64


Friday, March 18, 2016 12:52 PM | 3 votes

Found a solution if anyone else is looking for this. This queries systems that have a GPT system partition. Where you have a GPT system partition is most of the cases where UEFI is enabled.

Select * from Win32_DiskPartition Where Type = "GPT: System"


Friday, February 16, 2018 2:49 PM | 3 votes

Full command below:

Get-WmiObject  -query 'Select * from Win32_DiskPartition Where Type = "GPT: System"'

If the system has GPT partition on the main boot drive it's likely UEFI...