PHP Classes

PHP List Windows Drives: Retrieve the letters of the drives on Windows

Recommend this page to a friend!
  Info   View files Example   View files View files (3)   DownloadInstall with Composer Download .zip   Reputation   Support forum (1)   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStarStar 60%Total: 259 All time: 7,799 This week: 107Up
Version License PHP version Categories
win-logical-drives 1.0.0BSD License5.5PHP 5, System information, Windows


This package can retrieve the letters of the drives on Windows.

There is a class that can retrieve the list of all drive letters for assigned or unassigned drives using WMI (Windows Management Instrumentation) interface.

Another class can retrieve the details of each drive like the drive type, the network name, and whether it is a compact disk (CD), local disk, network drive, RAM disk, or a removable disk.

Innovation Award
PHP Programming Innovation award nominee
November 2016
Number 14
In Windows the different storage devices are defined by drives. Each drive has one letter assigned to it.

This package can retrieve the list of drives using the WMI interface, as well the characteristics of each drive.

Manuel Lemos
Picture of Christian Vigh
  Performance   Level  
Name: Christian Vigh <contact>
Classes: 32 packages by
Country: France France
Age: 57
All time rank: 13810 in France France
Week rank: 10 Up1 in France France Up
Innovation award
Innovation award
Nominee: 20x

Winner: 3x



        This example demonstrates how to use the various methods of the LogicalDrives class.

require ( 'LogicalDrives.phpclass' ) ;

    if (
php_sapi_name ( ) != 'cli' )
        echo (
"<pre>" ) ;

$ld = new LogicalDrives ( ) ;

// Show assigned drive letters, with their label
    // Note that the $ld object can be accessed as an array, providing the drive letter as an index
    // (the drive letter can be followed by an optional semicolon and is not case-sensitive)
echo ( "Assigned drives :\n" ) ;

    foreach (
$ld -> GetAssignedDrives ( ) as $drive_letter )
        echo (
"\t$drive_letter ({$ld [ $drive_letter ] -> VolumeName})\n" ) ;

// Show unassigned drives
echo ( "Unassigned drives : " . implode ( ', ', $ld -> GetUnassignedDrives ( ) ) . "\n" ) ;

// Next available drive letter
echo ( "Next available drive : " . $ld -> GetNextAVailableDrive ( ) . "\n" ) ;

  Files folder image Files  
File Role Description
Accessible without login Plain text file example.php Example Example script
Plain text file LogicalDrives.phpclass Class Class source
Accessible without login Plain text file Doc. Documentation

 Version Control Reuses Unique User Downloads Download Rankings  
This week:0
All time:7,799
This week:107Up
User Ratings User Comments (1)
 All time
excelent class
3 years ago (Luis Carrizo)