2009-12-22 105 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