how to report drives and labels?

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
CodeLobster

how to report drives and labels?

Post by CodeLobster »

how do i report all existing drives plus their labels?

it seems that i have to go to desktop then get (selecteditemsnames); but id

like to not go anywhere to get that info. options like drives names, labels or both

are welcome. thanks.

report template:
c: (drive name)
d: (drive name 2)
e: (optical drive)

Stefan
Posts: 1360
Joined: 18 Nov 2008 21:47
Location: Europe

Re: how to report drives and labels?

Post by Stefan »

Code: Select all

$i = 1; $a="";
  while($i <= 26){
      if (exists( chr(64 + $i) . ":")==2){
        $a = $a . chr(64 + $i) . ":" . ",";
      }
   $i++;
  }
  $a = substr($a,,-1); //remove trailing coma delimiter
  msg $a;


/*
---------------------------
XYplorer
---------------------------
C:,E:,T:,X:
---------------------------
OK   
---------------------------
*/

Code: Select all

 $VBScript = <<<HEREDOC
Set FSO = CreateObject("Scripting.FileSystemObject")
For x = 1 to 26
vol = chr(64 + x)  & ":\"
 IF FSO.DriveExists(vol) Then
      'msgbox vol & " exist"
      If Fso.GetDrive(vol).IsReady Then
        'msgbox vol & " is ready"
          Set objDrive = FSO.GetDrive(Fso.GetDriveName(vol))
          out = out & vol & " " & objDrive.VolumeName & vbCRLF
      End If
  End If
NEXT
'msgbox out
Set objOutputFile = FSO.CreateTextFile("C:\Temp\myDrives.txt", TRUE)
objOutputFile.Write(out)
objOutputFile.Close

HEREDOC;

  writefile("C:\Temp\myDrives.VBS", $VBScript);
  //wait 1000;
  run "wscript C:\Temp\myDrives.VBS",,1;
  $myDrv = readfile("C:\Temp\myDrives.txt");



  msg $myDrv;
/*
---------------------------
XYplorer
---------------------------
C:\ System
E:\ Data
T:\ Backup
X:\ Image
---------------------------
OK   
---------------------------
*/






   foreach($line, $myDrv, "<crlf>"){
      if($line==""){break;}
         $DL = gettoken($line, 1, " ");
         $DC = gettoken($line, 2, " ");
      msg $DL has caption $DC;
     }
/*
---------------------------
XYplorer
---------------------------
C:\ has caption System
---------------------------
OK   
---------------------------
*/



HTH? :D

CodeLobster

Re: how to report drives and labels?

Post by CodeLobster »

my expectation was that

Code: Select all

goto %computer%; $drives = folderreport("list", "r", , );
, which works, could be reduced to $drives = folderreport("list", "r", %computer%, ); but then its strangely broken.

Code: Select all

goto %computer%; sel a; $drives = report("{name}<crlf>", 1);
works either offering a better output but again i have to go to the folder.

thank you stefan for the options!!!

i leave my suggestion to devs.

Post Reply