开发者

WMI Access denied excptn

开发者 https://www.devze.com 2022-12-14 19:57 出处:网络
string s = Form1.ipadd; string devic; devic = comboBox1.Text; groupBox2.Text = devic + \"Information\";
 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 w开发者_Python百科hile accessing remote system......Accesses denied excption ...i shall b very thankful 2 your help.


The account that is running this code must have sufficient access on the remote machine. See this MSDN page. It also shows how to use impersonation, that may be a way to solve your problem.

0

精彩评论

暂无评论...
验证码 换一张
取 消