slloyd has asked for the wisdom of the Perl Monks concerning the following question:
UPDATE: Taking the excellent comments made, I have been able to come up with the following but when I run it, it accesses the floppy drive every time... I will still need to work on figuring out how to exclude the floppy drive seek unless specifically requested.
use strict; use warnings; use Win32::OLE qw(in); my $objWMIService = Win32::OLE->GetObject("winmgmts:{impersonationLeve +l=impersonate,(security)}//."); die "Error" unless $objWMIService; my $wmiDiskDrives = $objWMIService->ExecQuery("SELECT Caption, DeviceI +D, InterfaceType FROM Win32_DiskDrive"); print "Device Caption -> InterfaceType -> Drive Letter\n"; print "=" x 60 . "\n"; foreach my $wmiDiskDrive ( in( $wmiDiskDrives ) ) { my $deviceID=$wmiDiskDrive->{DeviceId}; $deviceID=~s/\\/\\\\/sg; my $map=qq|ASSOCIATORS OF {Win32_DiskDrive.DeviceID="$deviceID"} W +HERE AssocClass = Win32_DiskDriveToDiskPartition|; #print "$map\n"; my $wmipartitions = $objWMIService->ExecQuery($map); foreach my $wmipartition ( in( $wmipartitions ) ) { my $deviceID=$wmipartition->{DeviceId}; my $map=qq|ASSOCIATORS OF {Win32_DiskPartition.DeviceID="$devi +ceID"} WHERE AssocClass = Win32_LogicalDiskToPartition|; #print "\t$map\n"; my $wmiLogicalDisks = $objWMIService->ExecQuery($map); foreach my $wmiLogicalDisk ( in( $wmiLogicalDisks ) ) { my $drive=$wmiLogicalDisk->{DeviceId}; print join(" -> ", $wmiDiskDrive->{Caption}, $wmiDisk +Drive->{InterfaceType} , $wmiLogicalDisk->{DeviceId}); print "\n"; } } }
-------------------------------
by me
http://www.basgetti.com
http://www.kidlins.com
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Is a drive USB, IDE or SCSI?
by BrowserUk (Patriarch) on Dec 02, 2005 at 08:34 UTC | |
by slloyd (Hermit) on Dec 02, 2005 at 17:32 UTC | |
by BrowserUk (Patriarch) on Dec 02, 2005 at 18:40 UTC | |
|
Re: Is a drive USB, IDE or SCSI?
by kulls (Hermit) on Dec 02, 2005 at 08:23 UTC | |
by slloyd (Hermit) on Dec 02, 2005 at 17:28 UTC | |
|
Re: Is a drive USB, IDE or SCSI?
by psychotic (Beadle) on Dec 02, 2005 at 17:41 UTC | |
by slloyd (Hermit) on Dec 03, 2005 at 15:01 UTC | |
by psychotic (Beadle) on Dec 03, 2005 at 15:22 UTC | |
by slloyd (Hermit) on Dec 03, 2005 at 15:33 UTC | |
|
Re: Is a drive USB, IDE or SCSI?
by planetscape (Chancellor) on Dec 02, 2005 at 19:02 UTC | |
| A reply falls below the community's threshold of quality. You may see it by logging in. |