English 中文(简体)
Can t read from RSOP_RegistryPolicySetting WMI class in rootRSOP namespace
原标题:

The class is documented in

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

And from this page it seems it s not an abstract class:

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

But whenever I run the code below I get an "Invalid Class" exception in ManagementObjectSearcher.Get(). So, does this class exist or not?

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}
", queryObj["id"]);
    wmiResults.Text += String.Format("precedence={0}
", queryObj["precedence"]);
    wmiResults.Text += String.Format("registryKey={0}
", queryObj["registryKey"]);
    wmiResults.Text += String.Format("valueType={0}
", queryObj["valueType"]);
}

In the first link above, it lists as a requirement something called a "MOF": "Rsopcls.mof". Is this something I should have but have not? How do I obtain it? Is it necessary in the querying machine or the queried machine? Or both?

I do have two copies of this file:

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

 Directory of C:WindowsSystem32wbem

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

 Directory of C:Windowswinsxsx86_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
最佳回答

Duh. I was using the wrong namespace. It was rootRSOPComputer.

问题回答

暂无回答




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签