【问题标题】:How to know if UWF is enabled or disabled如何知道 UWF 是启用还是禁用
【发布时间】:2017-08-25 07:59:00
【问题描述】:

我如何知道 UWF 是启用还是禁用? 我正在使用 C# 制作应用程序,因此我需要了解该语言。

谢谢

【问题讨论】:

    标签: c# windows-10 uwf uwfmgr


    【解决方案1】:

    在考虑是启用还是禁用 UWF 时,有几点需要牢记:

    1. 启用UWF时未启用保护,您需要使用UWF_Volume类中的Protect方法将其显式打开。
    2. 启用或禁用 UWF 后需要重新启动系统才能应用更改。 UWF_Filter 类提供了启用/禁用和执行系统重启/关闭的方法。

    下面的 C# 代码演示了如何使用 UWF_Filter 类的 CurrentEnabled 属性:

    public static bool IsEnabled()
        {
            try
            {
                //root\standardcimv2\embedded
                ManagementScope scope = new ManagementScope(@"root\standardcimv2\embedded");
                using (ManagementClass mc = new ManagementClass(scope.Path.Path, "UWF_Filter",
                null))
                {
                    ManagementObjectCollection moc = mc.GetInstances();
    
                    foreach (ManagementObject mo in moc)
                    {
                        // Please make use of NextEnabled property in case you have enabled the UWF_Filter in the current session. 
                        //The value in CurrentEnabled is populated only when the UWF_Filter was enabled on system boot.
                        return (bool)mo.GetPropertyValue("CurrentEnabled");
                    }
                }
    
    
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                throw;
            }
            return false;
        }
    

    注意/请求:请求1500 reputation 的人创建并链接以下标签,以便像我这样的人更容易在 stackoverflow 上请求解决方案/回答问题。

    1. UWF
    2. UWFMGR

    【讨论】:

    • 以非管理员用户身份运行,我发现这在过滤器被禁用时有效,但一旦过滤器实际启用,它就会返回访问被拒绝...
    猜你喜欢
    • 1970-01-01
    • 2012-11-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-01-03
    • 2014-08-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多