In Javascript, Drive object returned by the GetDrive method of FileSystemObject (FSO) provides the access to Path property. This Path property of Drive object returns the uppercase Letter followed by colon symbol “:” that represents the specified drive. You can identify the drive of the client’s PC through this Path property of Drive object. GetDrive method accepts the English alphabet representing drives of computer system for example A, C, D or E according to the number of drives found on client’s PC whose Path you want to retrieve. Path property returns the UNC shared name of the drive for the specified shared network drive. 

Example of Javascript Drive Object Path 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 drive letter in uppercase with colon at its end
    document.write("<b>Drive base Path :</b> " + driveObj.Path);

    document.write("<br />");

    document.write("<b>Drive base Path :</b> " 
                    + fso.GetDrive("\\\\my-PC\\E").Path);

    // Output: 
    // Drive base Path : C: 
    // Drive base Path : \\my-PC\E
</script>

Continue to next tutorial: Javascript FSO Drive Object RootFolder property to learn how to get the root path of the specified drive.

Recent JavaScript Tutorials

Javascript FSO ShortPath property

Javascript FileSystemObject (FSO) provides a ShortPath property that can be accessed using the folder object or file object returned by the GetFolder or GetFile method.

Javascript FSO Path Property

Javascript FileSystemObject (FSO) provides the Path property that can be accessed through the file object or folder object returned by the GetFile or GelFolder method

Javascript FSO Type property

Javascript FileSystemObject (FSO) provides a Type property that can be accessed through file object or folder object returned by the GetFile or GetFolder method

Javascript FSO ShortName property

Javascript FileSystemObject (FSO) provides a ShortName property that can be accessed using the folder object or file object returned by the GetFolder or GetFile method.

Javascript FSO Name Property

Javascript FileSystemObject (FSO) provides a Name property that can be accessed using file object or folder object.