I have been trying to find what BIOS mode is being used.
For example, I just want it to show either . . .
UEFI with secure boot disabled
UEFI with secure boot enabled
LEGACY boot enabled
I have looked at doing this from bcdedit /enum.
I have tried reg query HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\BIOS.
. . . along with many others.
I just can't seem to extract the information needed!
Thanks in advance.
[SOLVED] Find BIOS Mode.
Moderator: DosItHelp
[SOLVED] Find BIOS Mode.
Last edited by PAB on 07 Nov 2019 09:35, edited 1 time in total.
Re: Find BIOS Mode.
I don't see this information. Neither in the bcdedit output nor in the registry key. The only possibility I found is using a PowerShell cmdlet that you can call from within Batch.
Not sure about the legacy mode though. I don't have access to a computer without UEFI.
Steffen
Code: Select all
@echo off &setlocal
set "securemode="
set "biosmode="
for /f %%i in ('powershell.exe -nop -ep Bypass -c "Confirm-SecureBootUEFI"') do set "securemode=%%i"
if /i "%securemode%"=="False" (
set "biosmode=UEFI with secure boot disabled"
) else if /i "%securemode%"=="True" (
set "biosmode=UEFI with secure boot enabled"
) else (
powershell.exe -nop -ep Bypass -c "Confirm-SecureBootUEFI" | >nul find /i "PermissionDenied"
if errorlevel 1 (
set "biosmode=LEGACY boot enabled"
) else (
echo Access denied. Run the script as Administrator!
pause
exit /b
)
)
echo %biosmode%
pause
Steffen
Re: Find BIOS Mode.
That's brilliant Steffen.
I can confirm the code works on LEGACY mode.
So what would I use if I just needed to know if it was either UEFI or LEGACY please?
This produces LEGACY on my computer, does it produce UEFI on yours please?
Thank you.
I can confirm the code works on LEGACY mode.
So what would I use if I just needed to know if it was either UEFI or LEGACY please?
This produces LEGACY on my computer, does it produce UEFI on yours please?
Code: Select all
@echo off &setlocal
set "securemode="
set "biosmode="
for /f %%i in ('powershell.exe -nop -ep Bypass -c "Confirm-SecureBootUEFI"') do set "securemode=%%i"
if /i "%securemode%"=="False", "True" (
set "biosmode=UEFI - GPT."
) else (
powershell.exe -nop -ep Bypass -c "Confirm-SecureBootUEFI" | >nul find /i "PermissionDenied"
if errorlevel 1 (
set "biosmode=LEGACY-MBR."
)
echo %biosmode%
pause
Re: Find BIOS Mode.
No, that's definitely not how IF works. There has to be only one comparison operand on each side of the comparison operator. Your script throws an error message that "True" is not recognized as an internal or external command (can't recall the exact English wording though).
Possible work-around
Steffen
Possible work-around
Code: Select all
@echo off &setlocal
set "biosmode=UEFI"
powershell.exe -nop -ep Bypass -c "Confirm-SecureBootUEFI" | >nul findstr /ib "True False" || (
powershell.exe -nop -ep Bypass -c "Confirm-SecureBootUEFI" | >nul find /i "PermissionDenied"
if errorlevel 1 (
set "biosmode=LEGACY"
) else (
echo Access denied. Run the script as Administrator!
pause
exit /b
)
)
echo %biosmode%
pause