How can I view the system information ??

Dani AI

Generated

A compact, practical summary of options for viewing system information in VB.NET that complements the replies already in this thread. correctly called out WMI for the most detailed hardware and OS data; pointed to the VB "My" helpers for quick, built‑in values (VB 2005+). For older VB2003/.NET 1.1 there is no My shortcut, so lower‑level APIs or WMI are the usual choice.

Choice guide: use the VB My namespace (or Environment APIs) for basic labels (OS name, machine/user name, folders). Use WMI (System.Management) when CPU model, total physical memory, serial numbers, logical disk info, network adapter settings, or driver-level details are required. Typical Win32 classes to query include Win32_OperatingSystem, Win32_ComputerSystem, Win32_Processor, Win32_PhysicalMemory and Win32_LogicalDisk.

Example WMI pattern (add a reference to System.Management and import the namespace):

' Requires reference to System.Management
Imports System.Management

Sub DumpOS()
    Dim q As New ObjectQuery("SELECT Caption, Version FROM Win32_OperatingSystem")
    Using s As New ManagementObjectSearcher(q)
        For Each mo As ManagementObject In s.Get()
            Console.WriteLine("OS: " & Convert.ToString(mo("Caption")) & " - " & Convert.ToString(mo("Version")))
        Next
    End Using
End Sub

Practical tips and cautions: add a reference to System.Management, handle ManagementException, and run long queries off the UI thread. WMI can require the Windows Management Instrumentation service to be running and may need elevated rights or explicit credentials for remote machines; firewalls can block remote WMI. For cross‑platform code or modern .NET projects, avoid relying on WMI for non‑Windows targets and prefer platform‑appropriate APIs. For troubleshooting, verify WMI with tools like wbemtest and check service/permission problems before assuming code errors.

Recommended Answers

All 7 Replies

***Disregard this***

Use WMI

If you are using 2005 then use the My function.
My.Computer. will give you a list of things on or about your computer.

here is some vb 2003 code (net 1.1) to get inforamtion

Dim version As String
Dim build As String
Dim nt As Boolean
Dim ce As Boolean
Dim dos As Boolean
sysroot.Text = "System Root: " & Environment.GetFolderPath(Environment.SpecialFolder.System).ToString
domain.Text = "User: " & Environment.UserName.ToString & " on " & Environment.MachineName.ToString
Select Case Environment.OSVersion.Platform
Case PlatformID.Win32S
version = "Windows 3.x - Version "
Case PlatformID.Win32Windows
Select Case Environment.OSVersion.Version.Minor
Case 0
version = "Windows 95"
dos = True
Case 10
version = "Windows 98"
dos = True
Case 90
version = "Windows ME"
dos = True
Case Else
version = "Unknown Windows 9x Version "
dos = True
End Select
Case PlatformID.Win32NT
Select Case Environment.OSVersion.Version.Major
Case 3
version = "Windows NT 3.51"
nt = True
Case 4
version = "Windows NT 4"
nt = True
Case 5
Select Case Environment.OSVersion.Version.Minor
Case 0
version = "Windows 2k"
nt = True
Case 1
version = "Windows XP"
nt = True
Case 2
version = "Windows Server 2003"
nt = True
Case Else
version = "Unknown Windows NT Version"
nt = True
End Select
Case Else
version = "Unknown Windows NT Version"
nt = True
End Select
Case PlatformID.WinCE
version = "Windows CE / PocketPC"
ce = True
Case Else
version = "Unknown Windows CE Version"
ce = True
End Select
If nt = True Then
build = "NT " & Environment.OSVersion.Version.Major.ToString & "." & Environment.OSVersion.Version.Minor.ToString & " - Build " & Environment.OSVersion.Version.Build.ToString
ElseIf ce = True Then
build = "CE " & Environment.OSVersion.Version.Major.ToString & "." & Environment.OSVersion.Version.Minor.ToString & " - Build " & Environment.OSVersion.Version.Build.ToString
ElseIf dos = True Then
build = "Windows " & Environment.OSVersion.Version.Major.ToString & "." & Environment.OSVersion.Version.Minor.ToString & " - Build " & Environment.OSVersion.Version.Build.ToString
Else
version = version
End If
 
winver.Text = version
winbuild.Text = build

It will display the info lile in the picture

If you are using 2005 then use the My function.
My.Computer. will give you a list of things on or about your computer.

Is there an equivalent MY option in VB2003 .net?

no, you have to do what i did.

i want documentation fully about this

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.