in reply to Locating a flash drive on windows
use strict; use Win32::OLE('in'); use constant wbemFlagReturnImmediately => 0x10; use constant wbemFlagForwardOnly => 0x20; my $flashdriveletter; my $flashdrivename = 'foo'; my $computer = "."; my $objWMIService = Win32::OLE->GetObject("winmgmts:\\\\$computer\\roo +t\\CIMV2") or die "WMI connection failed.\n"; my $colItems = $objWMIService->ExecQuery("SELECT * FROM Win32_LogicalD +isk","WQL",wbemFlagReturnImmediately | wbemFlagForwardOnly); foreach my $objItem (in $colItems) { if ( $objItem->{VolumeName} eq /$flashdrivename/ ) { $flashdriveletter = $objItem->{Caption}; } }
The page lists about a zillion other attributes of the drive you can get from $objitem.
Steve
|
|---|