简体   繁体   English

WMI访问被拒绝

[英]WMI Access denied excptn

 string s = Form1.ipadd;
            string devic;
            devic = comboBox1.Text;
            groupBox2.Text = devic + "  Information";
            ConnectionOptions _Options = new ConnectionOptions();
            _Options.Username = "Babar";
            _Options.Password = "";
            ManagementPath _Path = new ManagementPath(s);

            ManagementScope _Scope = new ManagementScope(_Path, _Options);
            _Scope.Connect();
            ManagementObjectSearcher srcd = new ManagementObjectSearcher("select * from "+devic);
            tsprogress.Value = 0;
            Allplabel.Text = " : 0%";
            foreach (ManagementObject obj in srcd.Get())
            {


                //listBox5.Items.Add(obj.Properties.ToString());
                foreach (PropertyData aProperty in obj.Properties)
                {
                    i++;
                    tsprogress.Value = (i / cont) * 100;
                    Allplabel.Text = tsprogress.Value.ToString() + "%";
                    richTextBox1.AppendText(aProperty.Name.ToString() + " : " + aProperty.Value+"\n");


                }

            }

///////////////////////// The above code works fine on local host but does not works while accessing remote system......Accesses denied excption ...i shall b very thankful 2 your help. ///////////////////////上面的代码在本地主机上工作正常,但在访问远程系统时不起作用...我将非常感激2您的帮助。

The account that is running this code must have sufficient access on the remote machine. 运行此代码的帐户必须在远程计算机上具有足够的访问权限。 See this MSDN page . 请参阅此MSDN页面 It also shows how to use impersonation, that may be a way to solve your problem. 它还显示了如何使用模拟,这可能是解决问题的一种方式。

The problem looks like the same, you've asked for in another question . 这个问题看起来就像您在另一个问题中提出的一样 See my answer there. 在那里查看我的答案。

br--mabra 布拉马

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM