Created
January 10, 2023 21:25
-
-
Save butageek/d3fb56c8d6d41e3bd200a536ff5dfc27 to your computer and use it in GitHub Desktop.
Fix BCDBootEX When Using Windows ADK
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<job id="FixUEFIDetection"> | |
<script language="VBScript" src="ZTIUtility.vbs"/> | |
<script language="VBScript"> | |
' // *************************************************************************** | |
' // | |
' // File: FixUEFIDetection.wsf | |
' // | |
' // Version: 1.1 | |
' // | |
' // Author: Johan Arwidmark, @jarwidmark | |
' // | |
' // *************************************************************************** | |
oLogging.CreateEntry "Checking if running in WinPE or Full Windows", LogTypeInfo | |
oLogging.CreateEntry "OSVersion is: " & oEnvironment.Item("OSVersion"), LogTypeInfo | |
If oEnvironment.Item("OSVersion") = "WinPE" Then | |
oLogging.CreateEntry "We are in WinPE, detecting firmware type from registry...", LogTypeInfo | |
' Getting firmware type from WinPE registry | |
PEFirmwareType = oShell.Regread("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\PEFirmwareType") | |
oLogging.CreateEntry "Firmware type from WinPE registry is " & PEFirmwareType, LogTypeInfo | |
If PEFirmwareType = "2" Then | |
oLogging.CreateEntry "Machine is configured for UEFI, setting the IsUEFI variable to True", LogTypeInfo | |
oEnvironment.Item("IsUEFI") = "true" | |
Else | |
oLogging.CreateEntry "Machine is configured for BIOS, setting the IsUEFI variable to False", LogTypeInfo | |
oEnvironment.Item("IsUEFI") = "false" | |
End If | |
Else | |
oLogging.CreateEntry "Detecting firmware type from Full Windows", LogTypeInfo | |
Set objShell = CreateObject("WScript.Shell") | |
Set objExecObject = objShell.Exec("bcdedit /enum BOOTMGR") | |
Do While Not objExecObject.StdOut.AtEndOfStream | |
strText = objExecObject.StdOut.ReadLine() | |
If Instr(strText, "\EFI\Microsoft\Boot\bootmgfw.efi") > 0 Then | |
oLogging.CreateEntry "Machine is configured for UEFI, setting the IsUEFI variable to True", LogTypeInfo | |
oEnvironment.Item("IsUEFI") = "true" | |
Exit Do | |
End If | |
Loop | |
If oEnvironment.Item("IsUEFI") = "true" Then | |
' All good, do nothing | |
Else | |
oEnvironment.Item("IsUEFI") = "false" | |
End If | |
End If | |
</script> | |
</job> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment