SerialNumber property of Javascript Drive object returned by the GetDrive method provided by the “Scripting.FileSystemObject” returns the serial number of the fixed drive partition, CD drive or any other supported drive type specified as a parameter of the GetDrive function. SerialNumber property returns the decimal system number output for the specified drive or network shared drive. SerialNumber property of FSO Drive object returns the same result as the Window’s command prompt “VOL” command returns. The only difference is command prompt shows the serial number in hex codes whereas javascript SerialNumber property returns the decimal numbers.
Example of Javascript Drive object SerialNumber Property
<script type="text/javascript">
// initialize ActiveXObject and create an object of Scripting.FileSystemObject.
var fso = new ActiveXObject("Scripting.FileSystemObject");
// Drive object reference set to driveObj variable
var driveObj = fso.GetDrive("C");
// returns the Serial number of the specified drive
document.write("<b>Serial Number :</b> "
+ driveObj.SerialNumber);
document.write("<br />");
document.write("<b>Serial Number :</b> "
+ fso.GetDrive("\\\\my-PC\\d").SerialNumber);
// Output:
// Serial Number : 1894513724
// Serial Number : 1279066198
</script>
Continue to next tutorial: Javascript FSO Drive Object ShareName property to learn how to get the UNC share name of the specified shared drive.