.NET、WMI - StdRegProv 未找到!

发布于 2024-09-27 02:56:11 字数 357 浏览 4 评论 0原文

正在做 ManagementObject obj = new ManagementObject(@"root\default:StdRegProv"); 抛出 ArgumentOutOfRangeException 以及

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

什么..????????????

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..????????????

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

泅人 2024-10-04 02:56:11

感谢您的回复。
我已经成功地通过这样的编码正确地获得了它:

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

范围像这样提前初始化

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 我也将它用于其他对象

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文