edainworks.com :: VGR :: get the volume ID of a given device on the (Windows) server.

Run :
the Volume ID of C: is

Code :
<?php
//
// getvolumeID.php : get any volumeID
//
//VGR10042003
//VGR21082009 ADDed code et enrobage
//

$drive='C:'; // adapt to your needs
// prepare command
$syscmd="dir $drive";
// execute, get results
$fp=popen($syscmd,'r');
if ($fp) { // ok
  // read 
  $continue=TRUE;
  while ((!feof ($fp))and $continue) {
    $buffer = fgets($fp, 4096);
    $continue=(strpos($buffer,'-')===FALSE); // the volumeID is the first that may contain a dash
  }
  // close
  pclose($fp);
  // extract information
  $expl=explode(' ',$buffer);
  $poubStr=$expl[count($expl)-1];
  // display
  echo "the Volume ID of $drive is $poubStr<BR>";
} else echo "the command '$syscmd' could not be executed";
//end
?>

Vincent Graux (VGR) for European Experts Exchange and Edažn Works  back to list of test scripts
Last update 2024-05-13 15:33:52