473,395 Members | 1,629 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Get Remote Computer Details

Hello,

I am writng an application to monitor various PC's on our network.
I am trying to get the method below to connect to a remote machine and give
me that machines details.

However every time I run it - it just returns the details for the host
machine - can anyone see where I am going wrong
is WMI the best way to this?

Any help would be appreciated, Thanks

private void GetDetails()
{
ConnectionOptions oConn = new ConnectionOptions();
oConn.Impersonation = ImpersonationLevel.Impersonate;

System.Management.ManagementScope oMs = new
System.Management.ManagementScope(\\SERVER, oConn);
System.Management.ObjectQuery oQuery = new
System.Management.ObjectQuery("select * from Win32_OperatingSystem");
ManagementObjectSearcher oSearcher = new
ManagementObjectSearcher(oMs,oQuery);
ManagementObjectCollection oReturnCollection = oSearcher.Get();

foreach( ManagementObject oReturn in oReturnCollection )
{
Console.WriteLine("Description: " + oReturn["Description"].ToString());
Console.WriteLine("FreePhysicalMemory: " +
oReturn["FreePhysicalMemory"].ToString());
Console.WriteLine("FreeVirtualMemory: " +
oReturn["FreeVirtualMemory"].ToString());
Console.WriteLine("InstallDate: " + oReturn["InstallDate"].ToString());
Console.WriteLine("LastBootUpTime: " +
oReturn["LastBootUpTime"].ToString());
Console.WriteLine("LocalDateTime: " +
oReturn["LocalDateTime"].ToString());
Console.WriteLine("Name: " + oReturn["Name"].ToString());
Console.WriteLine("Organization: " +
oReturn["Organization"].ToString());
Console.WriteLine("OSLanguage: " + oReturn["OSLanguage"].ToString());
Console.WriteLine("OSType: " + oReturn["OSType"].ToString());
Console.WriteLine("RegisteredUser: " +
oReturn["RegisteredUser"].ToString());
Console.WriteLine("SerialNumber: " +
oReturn["SerialNumber"].ToString());
Console.WriteLine("ServicePackMajorVersion: " +
oReturn["ServicePackMajorVersion"].ToString());
Console.WriteLine("ServicePackMinorVersion: " +
oReturn["ServicePackMinorVersion"].ToString());
}

}
Nov 16 '05 #1
2 10620
This is wrong:
System.Management.ManagementScope(\\SERVER, oConn);
Please check ManagementScope Constructor [C#] in MSDN for details and a
sample
Willy.

"Lloyd Taylor" <ll**********@yahoo.com> wrote in message
news:ey**************@TK2MSFTNGP15.phx.gbl... Hello,

I am writng an application to monitor various PC's on our network.
I am trying to get the method below to connect to a remote machine and
give me that machines details.

However every time I run it - it just returns the details for the host
machine - can anyone see where I am going wrong
is WMI the best way to this?

Any help would be appreciated, Thanks

private void GetDetails()
{
ConnectionOptions oConn = new ConnectionOptions();
oConn.Impersonation = ImpersonationLevel.Impersonate;

System.Management.ManagementScope oMs = new
System.Management.ManagementScope(\\SERVER, oConn);
System.Management.ObjectQuery oQuery = new
System.Management.ObjectQuery("select * from Win32_OperatingSystem");
ManagementObjectSearcher oSearcher = new
ManagementObjectSearcher(oMs,oQuery);
ManagementObjectCollection oReturnCollection = oSearcher.Get();

foreach( ManagementObject oReturn in oReturnCollection )
{
Console.WriteLine("Description: " + oReturn["Description"].ToString());
Console.WriteLine("FreePhysicalMemory: " +
oReturn["FreePhysicalMemory"].ToString());
Console.WriteLine("FreeVirtualMemory: " +
oReturn["FreeVirtualMemory"].ToString());
Console.WriteLine("InstallDate: " + oReturn["InstallDate"].ToString());
Console.WriteLine("LastBootUpTime: " +
oReturn["LastBootUpTime"].ToString());
Console.WriteLine("LocalDateTime: " +
oReturn["LocalDateTime"].ToString());
Console.WriteLine("Name: " + oReturn["Name"].ToString());
Console.WriteLine("Organization: " +
oReturn["Organization"].ToString());
Console.WriteLine("OSLanguage: " + oReturn["OSLanguage"].ToString());
Console.WriteLine("OSType: " + oReturn["OSType"].ToString());
Console.WriteLine("RegisteredUser: " +
oReturn["RegisteredUser"].ToString());
Console.WriteLine("SerialNumber: " +
oReturn["SerialNumber"].ToString());
Console.WriteLine("ServicePackMajorVersion: " +
oReturn["ServicePackMajorVersion"].ToString());
Console.WriteLine("ServicePackMinorVersion: " +
oReturn["ServicePackMinorVersion"].ToString());
}

}

Nov 16 '05 #2
That's it - thanks
"Willy Denoyette [MVP]" <wi*************@pandora.be> wrote in message
news:uV**************@TK2MSFTNGP15.phx.gbl...
This is wrong:
System.Management.ManagementScope(\\SERVER, oConn);


Please check ManagementScope Constructor [C#] in MSDN for details and a
sample
Willy.

"Lloyd Taylor" <ll**********@yahoo.com> wrote in message
news:ey**************@TK2MSFTNGP15.phx.gbl...
Hello,

I am writng an application to monitor various PC's on our network.
I am trying to get the method below to connect to a remote machine and
give me that machines details.

However every time I run it - it just returns the details for the host
machine - can anyone see where I am going wrong
is WMI the best way to this?

Any help would be appreciated, Thanks

private void GetDetails()
{
ConnectionOptions oConn = new ConnectionOptions();
oConn.Impersonation = ImpersonationLevel.Impersonate;

System.Management.ManagementScope oMs = new
System.Management.ManagementScope(\\SERVER, oConn);
System.Management.ObjectQuery oQuery = new
System.Management.ObjectQuery("select * from Win32_OperatingSystem");
ManagementObjectSearcher oSearcher = new
ManagementObjectSearcher(oMs,oQuery);
ManagementObjectCollection oReturnCollection = oSearcher.Get();

foreach( ManagementObject oReturn in oReturnCollection )
{
Console.WriteLine("Description: " +
oReturn["Description"].ToString());
Console.WriteLine("FreePhysicalMemory: " +
oReturn["FreePhysicalMemory"].ToString());
Console.WriteLine("FreeVirtualMemory: " +
oReturn["FreeVirtualMemory"].ToString());
Console.WriteLine("InstallDate: " +
oReturn["InstallDate"].ToString());
Console.WriteLine("LastBootUpTime: " +
oReturn["LastBootUpTime"].ToString());
Console.WriteLine("LocalDateTime: " +
oReturn["LocalDateTime"].ToString());
Console.WriteLine("Name: " + oReturn["Name"].ToString());
Console.WriteLine("Organization: " +
oReturn["Organization"].ToString());
Console.WriteLine("OSLanguage: " + oReturn["OSLanguage"].ToString());
Console.WriteLine("OSType: " + oReturn["OSType"].ToString());
Console.WriteLine("RegisteredUser: " +
oReturn["RegisteredUser"].ToString());
Console.WriteLine("SerialNumber: " +
oReturn["SerialNumber"].ToString());
Console.WriteLine("ServicePackMajorVersion: " +
oReturn["ServicePackMajorVersion"].ToString());
Console.WriteLine("ServicePackMinorVersion: " +
oReturn["ServicePackMinorVersion"].ToString());
}

}


Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: James Watts | last post by:
Hi I am running 2003 server. A program that I use called Maximizer uses portals into addressbooks. The portals run on ASP.NET (I think... *.aspx) When I try to log on to the portals from a...
3
by: Lamont | last post by:
VB.NET Can anyone tell me how I can get the Drive Space information from a remote computer on the same domain and physical network? Primarily I need the Total disk space and space used or free...
1
by: Bhavya Shah | last post by:
Hello All, I am facing a serious problem while copying a file to a remote computer programmatically. What I want to do: I want to connect to a remote computer and copy a file to the remote...
1
by: Chidvilas | last post by:
// Get all processes running on the remote computer. Process remoteAll = Process.GetProcesses("XYZ"); when I am exectuing the above code, it is giving excetpion saying "Couldn't get process...
0
by: py | last post by:
I am trying to execute a batch script on a remote computer. The batch script looks like: @echo off start c:\python24\python.exe c:\a_script.py Here's the setup: Computer A (my computer),...
1
by: schaf | last post by:
Hi all! I'm still trying to start/stop a service on a remote computer. (I promiss that's the last new post because of this problem from my side) My situation: I've an application running under...
5
by: Sin Jeong-hun | last post by:
I need to read some registry keys of a remote computer. The key will be any key users provide. (For example : HKEY_CURRENT_USER\SOFTWARE \MyGame) I found that there was a handy method called...
2
by: SayamiSuchi | last post by:
-------------------------------------------------------------------------------- Hi, I have made one web application using Asp dot net 2005 and sql server 2005.The sql server i am connecting is...
0
by: mradula | last post by:
I want to register some remote computer with my web site and after that I want to check the on-line status of the registered computers over the internet. More details: If I register computer A, B,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.