如果我使用此WMI method '.IsEnabled',我应该关注我在if语句中处理结果的方式。如果方法返回bool值,我仍然可以使用Not或者我应该使用
if myStatus <> 0 OR isTPMEnabled <> True then
这是我的代码
function isTPMReadyToBeOwned(myTPMService)
dim myStatus, isTPMEnabled, isTPMActivated, isTPMOwnershipAllowed
myStatus = myTPMService.IsEnabled(isTPMEnabled)
if myStatus <> 0 or not(isTPMEnabled) then
oLogging.CreateEntry "TPM isn't enable and must be enabled and activated manually, errorcode " & Hex(myStatus), LogTypeWarning
isTPMReadyToBeOwned = False
exit Function
end If
myStatus = myTPMService.IsActivated(isTPMActivated)
If myStatus <> 0 or not(isTPMActivated) then
oLogging.CreateEntry "TPM isn't active and must be activated manually, errorcode " & Hex(myStatus), LogTypeWarning
isTPMReadyToBeOwned = False
exit Function
end If
myStatus = myTPMService.isOwnershipAllowed(isTPMOwnershipAllowed)
if myStatus <> 0 or not(isTPMOwnershipAllowed) then
oLogging.CreateEntry "TPM ownership is not allowed, errorcode " & Hex(myStatus), LogTypeWarning
isTPMReadyToBeOwned = False
exit Function
end If
isTPMReadyToBeOwned = True
end Function
答案 0 :(得分:0)
不应将布尔表达式/变量与布尔文字进行比较,因为它会增加额外的复杂度(运算符和操作数)。所以使用Not isTPMEnabled
。由于Not
既不是函数也不是数组,不要使用param list / index(); reserve()用于优先覆盖的情况。
更新评论:
()在VBScript中也有很多函数
()只能是类型3。