Mendip Data Systems

Database applications for businesses and schools

LogoTransparent

 

Sub GetSysInfo()

 

 Dim strComputer As String

 Dim WMI(5) As String

 Dim objWMIService As Object

 Dim colItems As Object

 Dim objItem As Object

 Dim strProcessorIDs As String

 Dim Cnt As Integer, I As Integer, obj As Object

 

 WMI(0) = "Win32_Processor"

 WMI(1) = "Win32_ComputerSystem"

 WMI(2) = "Win32_BIOS"

 WMI(3) = "Win32_LogicalDisk"

 

 strComputer = "localhost"

 

 Set objWMIService = GetObject("winmgmts:" _

   & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

 

 CurrentDb.Execute "DELETE * FROM tblSysInfo"

 

 On Error Resume Next

 For I = LBound(WMI) To UBound(WMI)

   Cnt = 1

   Set colItems = objWMIService.ExecQuery("SELECT * FROM " & WMI(I) & "", , 48)

 

   For Each objItem In colItems

     

     For Each obj In objItem.properties_

       

       CurrentDb.Execute "INSERT INTO tblSysInfo(WMI, Computer, Property, PropertyValue )" & _

           " VALUES (""" & WMI(I) & Cnt & """,""" & strComputer & """,""" & obj.Name & """,""" & obj.Value & """)", dbFailOnError

     Next

     Cnt = Cnt + 1

   Next

 Next I

 

 Set objItem = Nothing

 Set colItems = Nothing

 Set objWMIService = Nothing

 

End Sub

Code Samples for Businesses, Schools & Personal Use

Updated 26/08/2018              Approx 0.8 MB

 

A recent forum thread comparing DBEngine(0)(0) vs CurrentDB prompted me to put together a simple app for collecting detailed information about a computer system.

 

Until now, I have used a number of functions using WMI and other approaches to obtain this information. However, I've now managed to obtain code that will collect almost all this information in one place.

 

When first run, this will run a routine to populate a table tblSysInfo containing details of your computer system / processor / BIOS / each hard drive or logical disk.

 

As there is a lot of information this may take 10-20 seconds (less if you have a shiny new PC!). The most useful parts are then copied into the table tblComputerInfo and displayed in the form frmComputerInfo so it is instantly available in future.

 

Table tblSysInfo has the following fields:

ID (autonumber PK), wmi (text 50), Computer(text 50), Property (text 50), PropertyValue (text 50)

 

The code used to populate it is adapted from something I found online (at Stackoverflow?)

 

Code:

Detailed System Info

Click the image to view a larger version ...

Screenshots

On my PC, this creates around 520 records

 

The summary table tblComputerInfo has these fields and 1 record:

ID (autonumber PK), ComputerName (text 20), Processor (text 100), RAM (text 50), OperatingSystem (text 50), AccessVersion (text 50)

 

To use this in your own applications, copy ALL the following items:

1. Both tables tblSysInfo and tblComputerInfo

2. Form frmComputerInfo

3. Module modSysInfo

 

These items are OPTIONAL:

4. Both queries - used for clearing the data in each table

5. Module modResizeForm - used to resize the form(s) for any screen resolution.

If you don't want to use it, remove the line ResizeForm Me from the Form_Open event and resize the form 'manually' as required.

 

Click to download:  System Info   (zipped)

SystemInfo Return to Code Samples Page