Read the Serial Number of a Disk

Read the Serial Number of a Disk

The new Microsoft Scripting Runtime library includes a FileSystemObject hierarchy containing several objects that let you obtain information about your drives, folders, and files. For example, you can retrieve the serial number of a disk using this code:

 ' Get the serial number of drive C:Dim fso As New Scripting.FileSystemObjectDim dr As Scripting.Drive' Get a reference to the Drive objectSet dr = fso.GetDrive("C")Print Hex$(dr.SerialNumber)

You can also easily check whether a drive has enough free space on it, using the Drive object’s FreeSpace property:

 Print "Drive C: has " & dr.FreeSpace " bytes free."

For more information, look on VB’s Help file under “Dictionary” and “FileSystemObject.”


About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist