tags:

views:

17

answers:

1

Hi. Doing ManagementObject obj = new ManagementObject(@"root\default:StdRegProv"); throws ArgumentOutOfRangeException as well as

ManagementClass regClass = new ManagementClass(new ManagementPath("StdRegProv"));
inParams= regClass.GetMethodParameters("GetStringValue"); //throws ManagementException "Not found"

What the..????????????

A: 

Thanx for your reply. I've managed to get it correctly by coding like this:

ManagementScope sc = (ManagementScope)scope.Clone();
            sc.Path.NamespacePath = "root\\default"; //StdRegProv is in there
            ManagementPath path = new ManagementPath(string.Format(@"\\{0}\root\Default:StdRegProv", sc.Path.Server));
            regClass = new ManagementClass(sc, path, null);

Scope is initialized earlier like this

ConnectionOptions c = new ConnectionOptions();
            c.Username = "User";
            c.Password = "Password";
            c.Authentication = AuthenticationLevel.Default;
            string path = @"\\Myserver\root\cimv2";
            scope = new ManagementScope(path, c);
            scope.Connect();    

//path is init to ...cimv2 b/c I use it for other objects too

Nickolodeon