forked from DeploymentResearch/DRFiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
FixUEFIDetection.wsf
60 lines (46 loc) · 1.95 KB
/
FixUEFIDetection.wsf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<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>