Click here to Skip to main content
15,889,372 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, I am unable to connect to windows 2008 from my dev box windows 7 through WMI! I have checked all settings in windows 2008 properly! But still am unable to connect to the system!

my sample code:


C#
_liManagementScope.Add(new ManagementScope("\\\\hostname\root\\CIMV2"));
foreach (ManagementScope item in _liManagementScope)
{
  item.Connect();
  ObjectQuery query = new ObjectQuery(
                      "SELECT * FROM Win32_OperatingSystem");
                      ManagementObjectSearcher searcher =
                      new ManagementObjectSearcher(item, query);
}


Any help would be greatly appreciated :)!!
Posted
Updated 5-Aug-11 0:21am
v2
Comments
_Zorro_ 5-Aug-11 6:26am    
Could you provide more information, like what error are you getting?
sujith9689 5-Aug-11 6:31am    
Hi zorro thanks fr ur quick reply! Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))...!! these is the error m getting when im trying to catch windows 2008 from my windows 7 machine! my code worked fine when m connecting with other windows 7! its throwin above error when m connecting to windows 2k3 n windows 2k8 servers!!

Set the ConnectionOptions for username and password:

C#
ConnectionOptions connection = new ConnectionOptions();
              connection.Username = userNameBox.Text;
              connection.Password = passwordBox.Text;
              connection.Authority = "ntlmdomain:DOMAIN";


see http://msdn.microsoft.com/en-us/library/ms257337(v=vs.80).aspx[^]
 
Share this answer
 
Have a look at some options discussed here[^] (in the access denied section) that may help you solve this error.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900