【问题标题】:Can't read from RSOP_RegistryPolicySetting WMI class in root\RSOP namespace无法从 root\RSOP 命名空间中的 RSOP_RegistryPolicySetting WMI 类读取
【发布时间】:2009-11-18 18:39:36
【问题描述】:

该类记录在

http://msdn.microsoft.com/en-us/library/aa375050%28VS.85%29.aspx

从这个页面看来它不是一个抽象类:

http://msdn.microsoft.com/en-us/library/aa375084%28VS.85%29.aspx

但是每当我运行下面的代码时,我都会在 ManagementObjectSearcher.Get() 中得到一个“无效类”异常。那么,这个类是否存在?

ManagementScope scope;
ConnectionOptions options = new ConnectionOptions();
options.Username = tbUsername.Text;
options.Password = tbPassword.Password;
options.Authority = String.Format("ntlmdomain:{0}", tbDomain.Text);
scope = new ManagementScope(String.Format("\\\\{0}\\root\\RSOP", tbHost.Text), options);
scope.Connect();
ManagementObjectSearcher searcher = new ManagementObjectSearcher(scope, new ObjectQuery("SELECT * FROM RSOP_RegistryPolicySetting"));
foreach (ManagementObject queryObj in searcher.Get())
{
    wmiResults.Text += String.Format("id={0}\n", queryObj["id"]);
    wmiResults.Text += String.Format("precedence={0}\n", queryObj["precedence"]);
    wmiResults.Text += String.Format("registryKey={0}\n", queryObj["registryKey"]);
    wmiResults.Text += String.Format("valueType={0}\n", queryObj["valueType"]);
}

在上面的第一个链接中,它列出了一个称为“MOF”的要求:“Rsopcls.mof”。这是我应该拥有但没有的东西吗?我如何获得它?是在查询机还是被查询机中需要?还是两者兼有?

我确实有这个文件的两个副本:

C:\Windows>dir rsop*.mof /s
 Volume in drive C has no label.
 Volume Serial Number is 245C-A6EF

 Directory of C:\Windows\System32\wbem

02/11/2006  05:22           100.388 rsop.mof
               1 File(s)        100.388 bytes

 Directory of C:\Windows\winsxs\x86_microsoft-windows-grouppolicy-base-mof_31bf3856ad364e35_6.0.6001.18000_none_f2c4356a12313758

19/01/2008  07:03           100.388 rsop.mof
               1 File(s)        100.388 bytes

     Total Files Listed:
               2 File(s)        200.776 bytes
               0 Dir(s)   6.625.456.128 bytes free

【问题讨论】:

    标签: c# wmi group-policy


    【解决方案1】:

    呃。我使用了错误的命名空间。它是 root\RSOP\Computer。

    【讨论】:

      猜你喜欢
      • 2012-11-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-03-31
      相关资源
      最近更新 更多