如何在 C# 中使用 WMI 查询从 UWF 获取注册表和文件排除项 [英] How to get registry and file exclusions from UWF using WMI query in C#

查看:25
本文介绍了如何在 C# 中使用 WMI 查询从 UWF 获取注册表和文件排除项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用 WMI 从 UWF 获取所有注册表排除和文件排除.

I want to get all registry exclusion and file exclusion from UWF, using the WMI.

我已经尝试从 UWF_RegistryFilter 类调用 GetExclusions 方法,但没有成功.

I've already tried to invoke GetExclusions methods from UWF_RegistryFilter class but of no luck.

我期待一个有效的示例代码,提前感谢您的帮助!

I am looking forward to a working sample code, thanks in advance for any help!

推荐答案

难点是从方法结果中读取出参数.Microsoft 网站 很难猜测如何使用 ManagementBaseObject 来读取输出参数.

The difficult part is to read the out parameters from the method result. There is no appropriate documentation available on Microsoft website and it's difficult to guess how ManagementBaseObject can be utilized for reading the out parameters.

为了找到解决方案,我尝试根据其他有据可查的 wmi 示例了解 WMI 如何利用 out 参数.请使用下面的C#代码,希望对您有所帮助:

In order to reach to a solution, I tried to develop an understanding of how WMI makes use of out parameters based on other well-documented wmi samples. Please use the C# code below, I hope it helps:

public static void GetRegistryExclusions()
    {

        ManagementScope scope = new ManagementScope(@"rootstandardcimv2embedded");
        using (ManagementClass mc = new ManagementClass(scope.Path.Path, "UWF_RegistryFilter",
        null))
        {
            ManagementObjectCollection moc = mc.GetInstances();
            foreach (ManagementObject mo in moc)
            {
                ManagementBaseObject[] result = (ManagementBaseObject[])mo.InvokeMethod("GetExclusions", null, null).Properties["ExcludedKeys"].Value;

                if (result != null)
                {
                    foreach (var r in result)
                    {
                        Console.WriteLine(r.GetPropertyValue("RegistryKey"));
                    }
                }
            }
        }
    }

注意/请求请求具有 1500 声望的人创建和链接以下标签,以便像我这样的人在 stackoverflow 上请求解决方案/回答问题变得更加容易.

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

这篇关于如何在 C# 中使用 WMI 查询从 UWF 获取注册表和文件排除项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆