Is there a simple way to use VBA.Environ$ to get the serial number of the active hard drive?
Is there a simple way to use VBA.Environ$ to get the serial number of the active hard drive?
Here is a short macro I have used to Dump all environ characteristics. When I ran it a moment ago, it did not show any serial numbers for hard drives.
however a quick google search found the following:![]()
Sub ENVIRON_DUMP() Dim nCount As Integer nCount = 1 Do Until Environ(nCount) = "" Cells(nCount, 1).Value = Environ(nCount) nCount = nCount + 1 Loop End Sub
http://excelexperts.com/getting-hard...-serial-number
I hope this helps
Last edited by alansidman; 12-13-2014 at 12:40 PM.
Alan עַם יִשְׂרָאֵל חַי
Change an Ugly Report with Power Query
Database Normalization
Complete Guide to Power Query
Man's Mind Stretched to New Dimensions Never Returns to Its Original Form
E.g.,![]()
Function DriveSerialNumber(sDriveSpec As String) As Long ' Returns the serial number of the specified drive ' sDriveSpec argument can be ' o a drive letter ("C") ' o a drive letter with a colon appended ("C:") ' o a drive letter with a colon and path separator appended ("C:\") ' o a network share specification ("\\computer2\share1") ' Returns 0 if not found On Error Resume Next DriveSerialNumber = CreateObject("Scripting.FileSystemObject").GetDrive(sDriveSpec).SerialNumber End Function
![]()
MsgBox DriveSerialNumber("C")
Entia non sunt multiplicanda sine necessitate
Try this line
![]()
Sub ShowHDSerial() Range("A1").Value = Hex(CreateObject("Scripting.FileSystemObject").Drives.Item("C:").SerialNumber) End Sub
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks