Javascript VolumeName property of FileSystemObject (FSO), Drive object returned by GetDrive method returns the volume label of the specified drive or network shared drive. VolumeName property of Drive object retrieves the name of the drive provided by the user to the specified drive. Javascript VolumName property returns the disk label only if the user has set its name, otherwise it does not return any value. This property is also same as the Window’s command prompt “VOL” command that returns the serial number as well as volume label
Example of Javascript Drive Object VolumeName 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 volume label of the specified drive
document.write("<b>Disk Label :</b> " + driveObj.VolumeName);
document.write("<br />");
document.write("<b>Disk Label :</b> "
+ fso.GetDrive("\\\\my-PC\\d").VolumeName);
// Output:
// Disk Label : Windows
// Disk Label : Shared Drive
</script>
Continue to next tutorial: Javascript FSO Attributes Property to learn how to get the attributes information about the specified file or folder.