473,395 Members | 1,941 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.

Computer Information in VB.NET

I'm new to VB.NET programming and would like some help on a little project
I've got going.
How would I go about getting computer information on my local computer, i.e.
serial number, hard drive size, memory installed, etc. Then take it one step
further and gather this info for all computers on a network.

I really appreciate any help on this,

Jim Scheffler
Jul 19 '05 #1
4 27600
WMI is your friend. Look at the ManagementObject classes and examples. This a C#
example for logical disks, but all you need to change is the target of the
select sttement and the properties you ask for. Doing it to remote computers is
"free". Just use a period for local system or the server name for remote.

public void LDisk ()
{
StringBuilder st = new StringBuilder ();
string servername = "somesystem";
ObjectQuery oq = new ObjectQuery("select * from Win32_Logicaldisk");
ManagementScope scope = new ManagementScope("\\\\" + servername +
"\\root\\cimv2");
scope.Connect();
ManagementObjectSearcher sea = new ManagementObjectSearcher(scope, oq);
foreach (ManagementObject proc in sea.Get())
{
st.AppendFormat ("Desc = {0}, ID={1}, Volname={2}", proc["Description"],
proc["Deviceid"],proc["VolumeName"]);
st.AppendFormat("\n");
}
MessageBox.Show (st.ToString());
}

--
Phil Wilson [MVP Windows Installer]
----
"Jim Scheffler" <Ji*****@charter.com> wrote in message
news:eP**************@TK2MSFTNGP12.phx.gbl...
I'm new to VB.NET programming and would like some help on a little project
I've got going.
How would I go about getting computer information on my local computer, i.e.
serial number, hard drive size, memory installed, etc. Then take it one step
further and gather this info for all computers on a network.

I really appreciate any help on this,

Jim Scheffler

Jul 19 '05 #2
Thanks Phil, That does look like exactly what I'm looking
for. I will check into it.

Jim
-----Original Message-----
WMI is your friend. Look at the ManagementObject classes and examples. This a C#example for logical disks, but all you need to change is the target of theselect sttement and the properties you ask for. Doing it to remote computers is"free". Just use a period for local system or the server name for remote.
public void LDisk ()
{
StringBuilder st = new StringBuilder ();
string servername = "somesystem";
ObjectQuery oq = new ObjectQuery("select * from Win32_Logicaldisk"); ManagementScope scope = new ManagementScope("\\\\" + servername +"\\root\\cimv2");
scope.Connect();
ManagementObjectSearcher sea = new ManagementObjectSearcher(scope, oq); foreach (ManagementObject proc in sea.Get())
{
st.AppendFormat ("Desc = {0}, ID={1}, Volname={2}", proc["Description"],proc["Deviceid"],proc["VolumeName"]);
st.AppendFormat("\n");
}
MessageBox.Show (st.ToString());
}

--
Phil Wilson [MVP Windows Installer]
----
"Jim Scheffler" <Ji*****@charter.com> wrote in message
news:eP**************@TK2MSFTNGP12.phx.gbl...
I'm new to VB.NET programming and would like some help on a little project I've got going.
How would I go about getting computer information on my local computer, i.e. serial number, hard drive size, memory installed, etc. Then take it one step further and gather this info for all computers on a network.
I really appreciate any help on this,

Jim Scheffler

.

Jul 19 '05 #3
Hello,

Here is an update on this project I'm working on,

So far I've been able to get information from my local computer using the
code below,

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Dim search As New ManagementObjectSearcher("SELECT * FROM Win32_BIOS")

Dim search2 As New ManagementObjectSearcher("SELECT * FROM
Win32_ComputerSystem")

Dim search3 As New ManagementObjectSearcher("SELECT * FROM Win32_Processor")

Dim info As ManagementObject

For Each info In search.Get()

TextBox1.Text = "Serial Number: " & info("serialnumber").ToString() & CRLF

TextBox1.Text += "Manufacturer: " & info("Manufacturer").ToString() & CRLF

Next

For Each info In search2.Get()

TextBox1.Text() += "Model: " & info("Model").ToString() & CRLF

TextBox1.Text() += "Computer Name: " & info("Name").ToString() & CRLF

TextBox1.Text() += "User Name Logged in: " & info("UserName").ToString() &
CRLF & CRLF

TextBox1.Text() += "Total Physical Memory: " &
info("TotalPhysicalMemory").ToString() & (" KB of Ram") & CRLF

Next

For Each info In search3.Get()

TextBox1.Text() += "CPU Clock Speed: " & info("Name").ToString() & CRLF

Next

End Sub

Some of this code was cut and pasted from other snips of code I found on the
internet and some of it I wrote myself, I'm still new at this.

Anyhow, now I want to get this info from computers on my network. From what
I read WMI is using the default namespace or local computer to get this
info. How would I code in a different computer to get this info? I can't
seem to find any good examples of this on the web.

Thanks,

Jim

"Jim Scheffler" <Ji*****@charter.com> wrote in message
news:eP**************@TK2MSFTNGP12.phx.gbl...
I'm new to VB.NET programming and would like some help on a little project
I've got going.
How would I go about getting computer information on my local computer, i.e. serial number, hard drive size, memory installed, etc. Then take it one step further and gather this info for all computers on a network.

I really appreciate any help on this,

Jim Scheffler

Jul 21 '05 #4
You want to set the Scope property on the ManagementObjectSearcher.
http://msdn.microsoft.com/library/en...ScopeTopic.asp

http://msdn.microsoft.com/library/en...ClassTopic.asp

In C# it looks something like this:
System.Management.ConnectionOptions options = new
System.Management.ConnectionOptions();
options.Username = "username"; //could be in domain\user format
options.Password = "Secret!!!";
// specify the path to the remote machine (un-double the slashes for VB)
System.Management.ManagementScope scope = new
System.Management.ManagementScope("\\\\machine\\ro ot\\cimv2", options);

// Get the list of configured printers:
string strQuery= "SELECT * FROM Win32_Printer";
System.Management.ObjectQuery oq = new
System.Management.ObjectQuery(strQuery);
System.Management.ManagementObjectSearcher query1 = new
System.Management.ManagementObjectSearcher(scope, oq);
System.Management.ManagementObjectCollection queryCollection1 =
query1.Get();

-Dino
Microsoft
"Jim Scheffler" <Ji*****@charter.com> wrote in message
news:el**************@tk2msftngp13.phx.gbl...
Hello,

Here is an update on this project I'm working on,

So far I've been able to get information from my local computer using the
code below,

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Dim search As New ManagementObjectSearcher("SELECT * FROM Win32_BIOS")

Dim search2 As New ManagementObjectSearcher("SELECT * FROM
Win32_ComputerSystem")

Dim search3 As New ManagementObjectSearcher("SELECT * FROM Win32_Processor")
Dim info As ManagementObject

For Each info In search.Get()

TextBox1.Text = "Serial Number: " & info("serialnumber").ToString() & CRLF

TextBox1.Text += "Manufacturer: " & info("Manufacturer").ToString() & CRLF

Next

For Each info In search2.Get()

TextBox1.Text() += "Model: " & info("Model").ToString() & CRLF

TextBox1.Text() += "Computer Name: " & info("Name").ToString() & CRLF

TextBox1.Text() += "User Name Logged in: " & info("UserName").ToString() &
CRLF & CRLF

TextBox1.Text() += "Total Physical Memory: " &
info("TotalPhysicalMemory").ToString() & (" KB of Ram") & CRLF

Next

For Each info In search3.Get()

TextBox1.Text() += "CPU Clock Speed: " & info("Name").ToString() & CRLF

Next

End Sub

Some of this code was cut and pasted from other snips of code I found on the internet and some of it I wrote myself, I'm still new at this.

Anyhow, now I want to get this info from computers on my network. From what I read WMI is using the default namespace or local computer to get this
info. How would I code in a different computer to get this info? I can't
seem to find any good examples of this on the web.

Thanks,

Jim

"Jim Scheffler" <Ji*****@charter.com> wrote in message
news:eP**************@TK2MSFTNGP12.phx.gbl...
I'm new to VB.NET programming and would like some help on a little project I've got going.
How would I go about getting computer information on my local computer,

i.e.
serial number, hard drive size, memory installed, etc. Then take it one

step
further and gather this info for all computers on a network.

I really appreciate any help on this,

Jim Scheffler


Jul 21 '05 #5

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

Similar topics

25
by: tnrABC | last post by:
The approximately 100 books below are for sale. Mostly a selection of mathematics (numerical analysis mostly), computing science (graphics, ai, programming techniques, theory, compilers, operating...
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...
0
by: ¿ Mahesh Kumar | last post by:
Hi all, 1. I want to retrieve My Computer info such as CD's, Floopies etc using code..? I mean my application should notice me if any external IO drives attached to my system.. Thnks. ...
5
by: z. f. | last post by:
i need to get the computer name from an aspx page. i use System.Windows.Forms.SystemInformation.ComputerName() and it's working fine, but in second thought, it might not be recomended to use the...
6
by: Jim Scheffler | last post by:
I'm new to VB.NET programming and would like some help on a little project I've got going. How would I go about getting computer information on my local computer, i.e. serial number, hard drive...
7
by: =?Utf-8?B?TWljaGFlbCBkZSBWZXJh?= | last post by:
to all, I was wondering if anyone has sample code that I can use to get information about a computer in active directory. For example, I want to know the date to when a computer was joined to a...
0
by: Winder | last post by:
Computer Data Recovery Help 24/7 Data recovering tools and services is our focus. We will recover your data in a cost effective and efficient manner. We recover all operating systems and media....
0
by: =?Utf-8?B?R3JlZw==?= | last post by:
I'm working on a C# web-site application. I am interested in gathering some information about those that visit each page of my site. I'd like to log such information as Computer Name, Computer IP...
2
by: =?Utf-8?B?R3JlZw==?= | last post by:
Via C# Code-Behind files, how can I retrieve information about the client computer viewing my pages. I'm looking to gather information such as: Windows User Name Computer IP Address Computer...
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: 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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.