Voting

: eight minus two?
(Example: nine)

The Note You're Voting On

saivert at saivert dot com
16 years ago
How to get the volume label of a drive on Windows

<?php

function GetVolumeLabel($drive) {
// Try to grab the volume name
if (preg_match('#Volume in drive [a-zA-Z]* is (.*)\n#i', shell_exec('dir '.$drive.':'), $m)) {
$volname = ' ('.$m[1].')';
} else {
$volname = '';
}
return
$volname;
}

print
GetVolumeLabel("c");

?>

Note: The regular expression assumes a english version of Windows is in use. modify it accordingly for a different localized copy of Windows.

<< Back to user notes page

To Top