以下是我的情景:
我的服务器有两种可能的配置:2-TB硬盘不需要特殊处理,3-TB硬盘需要UEFI BIOS和GPT分区才能启动操作系统。
我正在尝试创建一个能够检测BIOS是“遗留”还是“UEFI”的安装USB密钥,并相应地执行部署脚本。
我努力寻找可以区分但无济于事的WMI。
我最接近解决方案的是这篇文章: http://social.technet.microsoft.com/Forums/en-US/winserverManagement/thread/6cbb488d-3062-4aad-b712-7a9e4d045b13
detectefi.exe在检测BIOS类型时效果很好,但我无法输出结果,所以我不知道如何使用它。
我有两个问题:
我可以使用任何WMI来区分我的2个设置。
(如果问题1的答案为否)是否有办法将结果从C ++编译的.exe文件输出到.txt或任何其他形式并使用结果(我没有C ++技能)在所有)
答案 0 :(得分:0)
如果有人对我如何解决问题感兴趣。我刚刚创建了一个链接到.exe
的vbs Set objShell = CreateObject("WScript.Shell")
Set objWshScriptExec = objShell.Exec("detectefi.exe")
Set objStdOut = objWshScriptExec.StdOut
dim isLegacy
dim isUefi
isLegacy = false
isUefi = false
While Not objStdOut.AtEndOfStream
strLine = objStdOut.ReadLine
if strLine = "Legacy" then
isLegacy = true
end if
if strLine = "UEFI" then
isUefi = true
end if
Wend
if isLegacy then
wscript.echo "this is legacy"
set objShell = Wscript.CreateObject("WScript.Shell")
objShell.Run "2TBdeploy.cmd",1,True
set objShell = Nothing
end if
if isUefi then
wscript.echo "this is UEFI"
set objShell = Wscript.CreateObject("WScript.Shell")
objShell.Run "3TBdeploy.cmd",1,True
set objShell = Nothing
end if
答案 1 :(得分:0)
在不使用任何特殊实用程序和使用Windows操作系统本机命令行的情况下,这非常容易检测。
BCDEDIT /ENUM
将为您提供默认的引导加载程序。这可以用来区分UEFI和BIOS机器,如下所示:
path \EFI\Microsoft\Boot\bootmgfw.efi
然后,您可以使用oShell.Exec
处理输出,如上所述。
答案 2 :(得分:-1)
导入os
如果os.path.exists(“/ sys / firmware / efi”): 打印“uefi” 其他: 打印“bios”