英文:
UWF: get CurrentEnabled value via VBS
问题
我正在尝试创建一个简单的VBScript脚本来获取UWF状态:
Set objWMIService = GetObject("winmgmts:\\.\root\StandardCimv2\embedded:UWF_Filter")
WScript.Echo objWMIService.CurrentEnabled
输出是null
,即使我以管理员身份运行也是如此。
英文:
I'm trying to create a simple vbs script to get UWF status:
Set objWMIService = GetObject("winmgmts:\\.\root\StandardCimv2\embedded:UWF_Filter")
WScript.Echo objWMIService.CurrentEnabled
The output is null
even if I run it as administrator.
答案1
得分: 2
我找到了解决方案:我需要查找UWF_Filter的实例。这是适用于UWF_filter的工作代码
Set uwfFilters = GetObject("winmgmts:\\.\root\StandardCimv2\embedded:UWF_Filter")
Set oInstances = uwfFilters.instances_()
For Each oInstance In oInstances
if oInstance.CurrentEnabled and oInstance.NextEnabled then
Echo "Enabled"
elseif oInstance.CurrentEnabled and not oInstance.NextEnabled then
Echo "Enabled (will be disabled)"
elseif not oInstance.CurrentEnabled and oInstance.NextEnabled then
Echo "Disabled (will be enabled)"
else
Echo "Disabled"
end if
Next
奖励点: 此脚本用于 BGInfo,因此您需要将 Wscript.Echo
替换为 Echo
。
英文:
I found the solution: I've to look for the instances of UWF_Filter. This is the working code for UWF_filter
Set uwfFilters = GetObject("winmgmts:\\.\root\StandardCimv2\embedded:UWF_Filter")
Set oInstances = uwfFilters.instances_()
For Each oInstance In oInstances
if oInstance.CurrentEnabled and oInstance.NextEnabled then
Wscript.Echo "Enabled"
elseif oInstance.CurrentEnabled and not oInstance.NextEnabled then
Wscript.Echo "Enabled (will be disabled)"
elseif not oInstance.CurrentEnabled and oInstance.NextEnabled then
Wscript.Echo "Disabled (will be enabled)"
else
Wscript.Echo "Disabled"
end if
Next
Bonus point: this script is intended for BGInfo, so you need to replace Wscript.Echo
with Echo
.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论