简体   繁体   中英

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.

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.

The problem looks like the same, you've asked for in another question . See my answer there.

br--mabra

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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