I am trying to display all fixed, removable and network drives of my web server.
PHP Version -> PHP 7.1.4 (cli) ( ZTS MSVC14 (Visual C++ 2015) x64 )
Apache Version -> Apache/2.4.26-dev (Win64)
OS Version -> Windows 10 Pro x64 [Version 10.0.15063]
PHP Code:
/* Create a new file system object */
$FileSystemObject = new COM('Scripting.FileSystemObject');
/* Get system drives */
$Drives = $FileSystemObject->Drives;
/* Possible drive types */
$DriveTypes = array("Unknown","Removable","Fixed","Network","CD-ROM","RAM Disk");
$SystemDrives = [];
/* Loop through drives */
foreach($Drives as $Drive ){
/* Get current drive options */
$DriveOptions = $FileSystemObject->GetDrive($Drive);
/* If drive is removable, fixed or network */
if (($DriveOptions->DriveType == 1)||($DriveOptions->DriveType == 2)||($DriveOptions->DriveType == 3)){
$SystemDrives[] = array( "DriveType" => $DriveTypes[$DriveOptions->DriveType],
"DrivePath" => $DriveOptions->Path,
"DriveLabel"=> $DriveOptions->VolumeName
);
}
}
/* Show drives */
print_r($SystemDrives);
Response:
Array
(
[0] => Array
(
[DriveType] => Fixed
[DrivePath] => C:
[DriveLabel] =>
)
)
Apache runs as SYSTEM. Mapped drive has full permissions for SYSTEM. Any ideas on what i am doing wrong? Thanks!