devxlogo

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.”

Charlie has over a decade of experience in website administration and technology management. As the site admin, he oversees all technical aspects of running a high-traffic online platform, ensuring optimal performance, security, and user experience.

See also  Seven Service Boundary Mistakes That Create Technical Debt

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.