UWF: get CurrentEnabled value via VBS

116 Views Asked by At

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

There are 1 best solutions below

0
On BEST ANSWER

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.