简体   繁体   中英

How to know if UWF is enabled or disabled

How do I know if the UWF is enabled or disabled? I'm making an application with C # so I need to know for that language.

Thank you

There are few things to keep in mind when considering whether UWF is enabled or disabled:

  1. Protection is not enabled when UWF is enabled, you need to exlicitly turn it ON by making use of Protect method in UWF_Volume class.
  2. A system reboot is required after enabling or disabling of UWF in order to apply the changes. UWF_Filter class provides methods for enable/disable and for performing reboot/shutdown of the system.

The C# code below demonstrates the use of CurrentEnabled property of UWF_Filter class:

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;
    }

Note/Request : Request someone with 1500 reputation to create and link following tags so that it becomes easier for people like me to request solutions/answer questions on stackoverflow.

  1. UWF
  2. UWFMGR

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM