Obtain detailed system info about your PC (1 Viewer)

Status
Not open for further replies.

isladogs

CID VIP
Local time
Today, 10:51
Joined
Jan 14, 2017
Messages
14,018
A recent 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. For example:



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 based on something I found online (at Stackoverflow?) & adapted slightly:

Code:
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

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.

I hope this is useful to others.
It could possibly be helpful to include a similar screenshot for your own computer if you are posting about performance issues with Access.

As this is a moderated area, please send me a PM if you have any questions or issues with this utility.

HINT: Some of the information in tblSysInfo will be very useful if you are attempting Security Challenge #2
 

Attachments

  • SystemInfo.zip
    115.7 KB · Views: 99
  • SystemInfo.PNG
    SystemInfo.PNG
    18.7 KB · Views: 369
Last edited:
Status
Not open for further replies.

Users who are viewing this thread

Top Bottom