Laptop Audit

  • Thread starter Thread starter Sam Wilson
  • Start date Start date
S

Sam Wilson

Hi,

A colleague is trying to do an audit of our company's laptops - I can get
processor information, computer name etc from Environ(x), but is there a way
to get the make & model of a computer?

Cheers,

Sam
 
You can get that information from the system registry. The values are
stored in HKEY_LOCAL_MACHINE\Hardware\Description\System\Bios. To see
these values manually, enter RegEdit into the Run dialog on the
Windows Start menu and expand the tree view nodes to display the
values.

For programmatic access.....

Download the following zip files:

http://www.cpearson.com/Zips/modRegistry.zip
http://www.cpearson.com/Zips/modFormatMessage.zip

Unzip these files to some folder. Then, in VBA, go to the File menu,
choose "Import File", navigate to the folder in which the files were
unzipped, and import modRegistry.bas and modFormatMessage.bas. This
will create two modules in your project: modRegistry, which wraps up
all Windows API functions for registry access into nice VBA-friendly
procedures; and modFormatMessage, which gets the text description of
any API errors that might occur.

With these modules, you can use code like:

Function GetSysManufacturer() As String
' http://www.cpearson.com/Zips/modRegistry.zip
' http://www.cpearson.com/Zips/modFormatMessage.zip
Dim Value As Variant
Value = RegistryGetValue(HKLM, _
"Hardware\Description\System\Bios", _
"SystemManufacturer")
If IsNull(Value) = True Then
GetSysManufacturer = vbNullString
Else
GetSysManufacturer = CStr(Value)
End If
End Function

Function GetSysProductName() As String
' http://www.cpearson.com/Zips/modRegistry.zip
' http://www.cpearson.com/Zips/modFormatMessage.zip
Dim Value As Variant
Value = RegistryGetValue(HKLM, _
"Hardware\Description\System\Bios", _
"SystemProductName")
If IsNull(Value) = True Then
GetSysProductName = vbNullString
Else
GetSysProductName = CStr(Value)
End If
End Function

Sub AAA()
Dim SysMfg As String
Dim SysModel As String
SysMfg = GetSysManufacturer()
SysModel = GetSysProductName()
Debug.Print SysMfg, SysModel
End Sub

The AAA procedure shows how to get the values and writes them to the
Immediate window.

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)
 
Back
Top