/build/static/layout/Breadcrumb_cap_w.png

UEFI/BIOS detection in Scripted Installation

Hi,
Been struggling with this for the past week, and couldn't find much online, so thought Id share my Pre-Installation task BAT script I have recently created so that we can use the same Scripted Installation whether we boot from UEFI or legacy BIOS means.
Basically it queries a registry key in WinPE to determine whether the boot was UEFI or Legacy and then runs one of 2 diskpart scripts depending on the outcome. I also wanted it self contained so the diskpart scripts are written on the fly rather than kept as dependencies

REG QUERY “HKLM\System\CurrentControlSet\Control” /v “PEFirmwareType” | Find “2”

IF %ERRORLEVEL% == 0 goto UEFI
IF %ERRORLEVEL% == 1 goto BIOS

goto END

:UEFI
(
ECHO select disk 0
ECHO clean
ECHO convert basic noerr
ECHO convert gpt noerr
ECHO create partition efi size=200
ECHO assign letter=s
ECHO format quick fs=FAT32
ECHO create partition msr size=128
ECHO create partition primary
ECHO assign letter=c
ECHO format quick fs=NTFS
ECHO exit
)>X:\Windows\System32\UEFI.txt
diskpart /s X:\Windows\System32\UEFI.txt
goto END

:BIOS
(
ECHO select disk 0
ECHO clean
ECHO convert basic noerr
ECHO convert mbr noerr
ECHO create partition primary size=500
ECHO select partition 1
ECHO active
ECHO assign letter=s
ECHO format quick fs=NTFS
ECHO create partition primary
ECHO select partition 2
ECHO assign letter=c
ECHO format quick fs=NTFS
ECHO exit
)>X:\Windows\System32\BIOS.txt
diskpart /s X:\Windows\System32\BIOS.txt
bootsect.exe /NT60 c:
goto END

:END


Obviously the diskpart commands can be changed to suit whatever your needs. Hopefully will help someone!

Obviously provided as is with no support.


Comments

  • Copied and saved, thanks! - nheyne 7 years ago
  • Very interesting, thank you.
    For a cleaner way of doing it you may replace "X:\Windows\System32" by "%TEMP%" . - gwir 7 years ago
    • Never crossed my mind, as the X: refers to the boot environment so the file is not stored indefinetly. But that is a cleaner way of doing things. Thanks! - rjonesdj 7 years ago
  • Has anyone had this work for them? I am wondering what I am doing wrong. - dunnenick 7 years ago
    • still works for me, use it day in day out. Though I dont think our 2200 is up to date, perhaps something has changed in the newest version?
      Things I would check:
      When it fails can you manually find the REG key in the first line? Is the X:\ path available? If not change to %TEMP%\ - rjonesdj 7 years ago
This post is locked

Don't be a Stranger!

Sign up today to participate, stay informed, earn points and establish a reputation for yourself!

Sign up! or login

Share

 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ