From https://groups.google.com/forum/#!to...ks/mY3kkus2gfE
Post by Michel Walsh (Vanderghast, Access MVP) on 9/19/2000 & 9/30/2000
Need to set a reference to "Microsoft WMI Scripting 1.1 Library" (1.2 in Access 2010)
Code:
Public Function GetVolumeSerialNumber(Drive As String) As String
Dim objs As WbemScripting.SWbemObjectSet
Dim obj As WbemScripting.SWbemObject
Set objs = GetObject("winmgmts:").ExecQuery("SELECT * FROM Win32_LogicalDisk WHERE DriveType=3 AND Name='" & Drive & "'")
For Each obj In objs
GetVolumeSerialNumber = obj.VolumeSerialNumber
Exit For
Next obj
End Function
Usage would be like:
Code:
Sub test()
Dim tmp As Variant
tmp = GetVolumeSerialNumber("C:")
Debug.Print tmp
End Sub
Note the colon......