#!/usr/bin/perl -w use strict; #find Windows drive letters and type of drive my $result = `fsutil fsinfo drives`; my @letters = ($result =~ /[A-Z]{1}:/g); my %drive_types; foreach my $ltr (@letters) { my $result = `fsutil fsinfo drivetype $ltr`; $result =~ s/\r\n$//; my $type = ($result =~ /-\s+(.*)/)[0]; $drive_types{$ltr}=$type; } foreach my $drive (sort keys %drive_types) { print "$drive is a $drive_types{$drive}\n"; } __END__ prints: A: is a Removable Drive C: is a Fixed Drive D: is a CD-ROM Drive E: is a Removable Drive F: is a Removable Drive H: is a Fixed Drive I: is a Fixed Drive #### my %drives; foreach my $drive ('A'..'Z') { my $all = `vol $drive: 2>&1`; next if ($all =~ m/system cannot find the path/); $drives{$drive} = ($all =~ /^\s*(.*)/)[0]; #first line } foreach my $drive (sort keys %drives) { print "$drive: $drives{$drive}\n"; } __END__ #prints........... A: The device is not ready. C: Volume in drive C is Main-Max D: The device is not ready. E: The device is not ready. F: The device is not ready. G: Volume in drive G is CIS27 H: Volume in drive H is Sata-1a I: Volume in drive I is SATA-1B