I have a Vb-script which store all removable drives' letters into a variable, As you know it contains both floppy and USB drives, I want to seperate them, I mean I want to store USB Drives' Letters in a variable and Floppy ones into another variable,
Here is the script:
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colDisks = objWMIService.ExecQuery _
("Select * from Win32_LogicalDisk")
Removable = ""
For Each objDisk in colDisks
if objDisk.DriveType = 2 then
if Removable > "" then
Removable = Removable & ";"
end if
Removable = Removable & objDisk.DeviceID & "\"
end if
Next
I'm using a software which can call VBScript. But it only support some kind of them like which I posted. So How can I do what I told?
Thanks in Advance.
You can also try this query
For further details check this link. Best of luck
Check objDisk.MediaType. Here you'll find a list of MediaTypes; at a first glance MediaType 1 ... 10 indicates a 'normal' floppy; in a quick check on my (virtual) machine, an USB drive showed a MediaType of Null (not even Zero for Unknown), so you'll have do be careful. At a second glance (talking about carefull): most defined media types identify floppies (some of them exotic). BTW - what about USB floppy drives?
As I can't test on a 'real' computer, you'll have to double check the following code:
my output is:
The null MediaType of my USBDrive may be a freakish accident. I tried to make tinkering with the evaluating of the MediaType easy by using a "Select Case True" control structure. VBScript will test the conditions of the Cases until the first true one, execute the corresponding statement(s), and 'break' to the End Select. So adding special cases and/or reordering cases is straightforward - just keep the IsNull check at first position.