2009-12-22 104 views
1
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"); 


       } 

      } 

///////////////////////// 上述代码在本地主机上正常工作,但在访问时不起作用远程系统......访问被拒绝exculat ...我将非常感激2你的帮助。WMI访问拒绝excptn

+2

错误消息非常特殊:您正在运行该代码的凭据无权访问远程计算机。 – 2009-12-22 15:36:08

回答

1

运行此代码的帐户必须在远程计算机上具有足够的访问权限。请参阅this MSDN page。它还展示了如何使用模拟,这可能是一种解决问题的方法。

0

问题看起来像一样,你要求在another question。在那里看到我的答案。

br - mabra