Introduction
Do you need to know if another user is logged on a remote computer (before connecting with Remote Desktop Connection)?
Do you have enough disk space to install patches?
This utility answers those questions and uses WMI to query basic system information (system name and manufacturer, total system memory, logged on user,
OS details, networking details, type of computer, drive details, and BIOS details).
Background
I needed a tool like this to support remote computers on the domain at work. I had to ensure no other users were currently using the computer (or still logged on)
before remoting into their system to install software/patches or troubleshoot an issue.
Using the Code
Start by pinging the local or remote system:
Private Function Valid_Ping(ByVal SystemName As String)
Dim PingReplied As Boolean = False
Try
Dim PingSender As New Ping
Dim Options As New PingOptions
Options.DontFragment = True
Dim PingData As String = "******Computer*****Details******"
Dim Pingbuffer() As Byte = Encoding.ASCII.GetBytes(PingData)
Dim PingTimeout As Integer = 120
Dim PingReply As PingReply = PingSender.Send(SystemName, PingTimeout, Pingbuffer)
If PingReply.Status = IPStatus.Success Then
PingReplied = True
Else
PingReplied = False
End If
Return PingReplied
Catch ex As Exception
Return PingReplied
End Try
End Function
Check if you have the correct permissions to obtain the WMI information.
Private Sub Lookup_Details(ByVal SystemName As String)
PermChar_Label.Text = String.Empty
Me.Update()
Try
Dim MyConOptions As New System.Management.ConnectionOptions
With MyConOptions
.Impersonation = System.Management.ImpersonationLevel.Impersonate
.Authentication = System.Management.AuthenticationLevel.Packet
End With
Dim MyMgtScope As System.Management.ManagementScope
MyMgtScope = New System.Management.ManagementScope("\\" & _
SystemName & "\root\cimv2", MyConOptions)
MyMgtScope.Connect()
If MyMgtScope.IsConnected = False Then
PermChar_Label.ForeColor = Color.Red
PermChar_Label.Text = "r"
Me.Update()
Exit Sub
End If
PermChar_Label.ForeColor = Color.Green
PermChar_Label.Text = "a"
Me.Update()
Obtain the WMI information (see the full source code).
Configuration options can be accessed via a curtain type dropdown screen (the panel height is incremented to open the panel).
Read the Computer_Details_Article.txt file above to see how I made this drop down window.
Private Sub ConfigurationOptions_Button_Click(sender As System.Object, _
e As System.EventArgs) Handles ConfigurationOptions_Button.Click
If ConfigurationOptions_Button.Text = "Show Configuration Options" Then
Details_GroupBox.SendToBack()
While Configuration_Panel.Height < 461
Configuration_Panel.Size = _
New Size(Configuration_Panel.Width, Configuration_Panel.Height + 1)
Me.Update()
End While
ConfigurationOptions_Button.Text = "Hide Configuration Options"
Else
While Configuration_Panel.Height > 22
Configuration_Panel.Size = _
New Size(Configuration_Panel.Width, Configuration_Panel.Height - 1)
Me.Update()
End While
ConfigurationOptions_Button.Text = "Show Configuration Options"
If RememberSettings_CheckBox.Checked Then
Dim RegVer As RegistryKey
RegVer = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Code_Project\\Computer_Details\\1.0", True)
If RegVer Is Nothing Then
Registry.CurrentUser.CreateSubKey("SOFTWARE\\Code_Project\\Computer_Details\\1.0")
End If
If (Not RegVer Is Nothing) Then
RegVer.SetValue("MFR_Model", MfrModel_CheckBox.Checked)
RegVer.SetValue("Memory", Memory_CheckBox.Checked)
RegVer.SetValue("User", User_CheckBox.Checked)
RegVer.SetValue("OS", OS_CheckBox.Checked)
RegVer.SetValue("Network", Net_CheckBox.Checked)
RegVer.SetValue("Case", Case_CheckBox.Checked)
RegVer.SetValue("Drive", HD_CheckBox.Checked)
RegVer.SetValue("BIOS", BIOS_CheckBox.Checked)
RegVer.Close()
End If
End If
End If
End Sub
Selected options can be written to the Registry then read upon starting the application next time.
Points of Interest
You can use this utility on the local computer to obtain system information, but you must right click on the application and select
"Run as administrator" (using a user account that has administrator rights on the remote computer) in order to obtain information from remote systems.
Here are the check sums of the Computer_Details.exe compiled application (verify file integrity prior to executing, or recompile to be on the safe side).
MD5 SHA-1
-------------------------------- ----------------------------------------
dfb1db9d1fe816cd70f2bc8a3e3e1851 f2751eb2c7e2a6154e0def178bcc4d7bf8f53710
History
- Version 1.0 - Published 20 Nov 2011.