Sign in to follow this  
Followers 0
rudi

Distinguish USB thumb drives from other "Removable" drives?

13 posts in this topic

#1 ·  Posted (edited)

Hi.

I'm just coding for someone a tool, that will search for thumb drives. I know, that Thumb Drives are of drive type = "Removable". Is there a more safe way to recognize "this is a thumb drive"?

Maybe there is again some WMI stuff that would offer more detailed information? (no clue)

Floppies also show up as removable. The USB external HDDs I've connected just right now show up as "Fixed": I would have expected, that these are "Removable" as well?

Regards, Rudi.

Edited by rudi

Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Share this post


Link to post
Share on other sites



Hi.

I'm just coding for someone a tool, that will search for thumb drives. I know, that Thumb Drives are of drive type = "Removable". Is there a more safe way to recognize "this is a thumb drive"?

Maybe there is again some WMI stuff that would offer more detailed information? (no clue)

Floppies also show up as removable. The USB external HDDs I've connected just right now show up as "Fixed": I would have expected, that these are "Removable" as well?

Regards, Rudi.

Hi there,

Search for Scriptomatic

and see Win32_DiskDrive

Cheers


Old Scriptology

Visual Ping 1.8 - Mass Ping Program with export to txt delimited.

Desktop 2 RGB and YMCK - Pick a color in the desktop and get the RGB and YMCK code.

Desktop 2 RGB - Pick a color in the desktop and get the RGB code.

ShootIT 1.0 - Screen Capture full and partial screen

[font="'Arial Black';"]Remember Remember The Fifth of November.[/font]

Share this post


Link to post
Share on other sites

I'm sure something here would help with some of your questions:

http://www.autoitscript.com/forum/index.ph...mp;highlite=usb


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Hi.

Search for Scriptomatic

and see Win32_DiskDrive

You're frustrating me :) scriptomatic shows me, that I know close to nothing about WMI :)

Joking aside:

The thumb drive I want to catch is in the output that one:

Availability: 
BytesPerSector: 512
Capabilities: 3,4,7
CapabilityDescriptions: 
Caption: USB Stick 2.0 ME USB Device
CompressionMethod: 
ConfigManagerErrorCode: 0
ConfigManagerUserConfig: Falsch
CreationClassName: Win32_DiskDrive
DefaultBlockSize: 
Description: Laufwerk
DeviceID: \\.\PHYSICALDRIVE7
ErrorCleared: 
ErrorDescription: 
ErrorMethodology: 
Index: 7

InterfaceType: USB
LastErrorCode: 
Manufacturer: (Standardlaufwerke)
MaxBlockSize: 
MaxMediaSize: 
MediaLoaded: Wahr
MediaType: Removable media other than   floppy
MinBlockSize: 
Model: USB Stick 2.0 ME USB Device
Name: \\.\PHYSICALDRIVE7
NeedsCleaning: 
NumberOfMediaSupported: 
Partitions: 1
PNPDeviceID: USBSTOR\DISK&VEN_USB&PROD_STICK_2.0_ME&REV_1100\AA04012900007508&0
PowerManagementCapabilities: 
PowerManagementSupported: 
SCSIBus: 
SCSILogicalUnit: 
SCSIPort: 
SCSITargetId: 
SectorsPerTrack: 63
Signature: -1022939624
Size: 1011709440
Status: OK
StatusInfo: 
SystemCreationClassName: Win32_ComputerSystem
SystemName: PC4-006
TotalCylinders: 123
TotalHeads: 255
TotalSectors: 1975995
TotalTracks: 31365
TracksPerCylinder: 255

I cannot see at all, how I should link that information to the drive letter showing up in Windows:

DriveLetter: B:

DriveType: Removable

DriveLabel:TREKSTOR

DriveSerial:2461668151

Thanks, Rudi.

Edit: Scriptomatic has a big disadvantage: on the right side, the radio button for : "Language: Autoit v3 ( )" is missing o:);)

Edit2: The main loop of Win32_DiskDrive is starting like this:

For Each objItem In colItems

How can I have a look INTO the structure of "ObjItem", maybe the drive letter and serial are included with this object and the code you pointed me to just doesn't display that content with the echos defined?

WScript.Echo "<Item>: " & objItem.<item>

Regards, Rudi.

Edited by rudi

Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Hi again

Got it :)

Use Win32_Volume o:)

This link to see how you can case in your script the DriveType :)

going a little futher, the following example only scans DriveType 2 that is the code for removable disks. After that you can delete $output 's that are not necessary

; Generated by AutoIt Scriptomatic November 28, 2008

$wbemFlagReturnImmediately = 0x10
$wbemFlagForwardOnly = 0x20
$colItems = ""
$strComputer = "localhost"

$Output=""
$Output &= "Computer: " & $strComputer  & @CRLF
$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")
$colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_Volume WHERE DriveType LIKE 2", "WQL", _
                                          $wbemFlagReturnImmediately + $wbemFlagForwardOnly)

If IsObj($colItems) then
   For $objItem In $colItems
      $Output &= "Access: " & $objItem.Access & @CRLF
      $Output &= "Automount: " & $objItem.Automount & @CRLF
      $Output &= "Availability: " & $objItem.Availability & @CRLF
      $Output &= "BlockSize: " & $objItem.BlockSize & @CRLF
      $Output &= "BootVolume: " & $objItem.BootVolume & @CRLF
      $Output &= "Capacity: " & $objItem.Capacity & @CRLF
      $Output &= "Caption: " & $objItem.Caption & @CRLF
      $Output &= "Compressed: " & $objItem.Compressed & @CRLF
      $Output &= "ConfigManagerErrorCode: " & $objItem.ConfigManagerErrorCode & @CRLF
      $Output &= "ConfigManagerUserConfig: " & $objItem.ConfigManagerUserConfig & @CRLF
      $Output &= "CreationClassName: " & $objItem.CreationClassName & @CRLF
      $Output &= "Description: " & $objItem.Description & @CRLF
      $Output &= "DeviceID: " & $objItem.DeviceID & @CRLF
      $Output &= "DirtyBitSet: " & $objItem.DirtyBitSet & @CRLF
      $Output &= "DriveLetter: " & $objItem.DriveLetter & @CRLF
      $Output &= "DriveType: " & $objItem.DriveType & @CRLF
      $Output &= "ErrorCleared: " & $objItem.ErrorCleared & @CRLF
      $Output &= "ErrorDescription: " & $objItem.ErrorDescription & @CRLF
      $Output &= "ErrorMethodology: " & $objItem.ErrorMethodology & @CRLF
      $Output &= "FileSystem: " & $objItem.FileSystem & @CRLF
      $Output &= "FreeSpace: " & $objItem.FreeSpace & @CRLF
      $Output &= "IndexingEnabled: " & $objItem.IndexingEnabled & @CRLF
      $Output &= "InstallDate: " & WMIDateStringToDate($objItem.InstallDate) & @CRLF
      $Output &= "Label: " & $objItem.Label & @CRLF
      $Output &= "LastErrorCode: " & $objItem.LastErrorCode & @CRLF
      $Output &= "MaximumFileNameLength: " & $objItem.MaximumFileNameLength & @CRLF
      $Output &= "Name: " & $objItem.Name & @CRLF
      $Output &= "NumberOfBlocks: " & $objItem.NumberOfBlocks & @CRLF
      $Output &= "PageFilePresent: " & $objItem.PageFilePresent & @CRLF
      $Output &= "PNPDeviceID: " & $objItem.PNPDeviceID & @CRLF
      $strPowerManagementCapabilities = $objItem.PowerManagementCapabilities(0)
      $Output &= "PowerManagementCapabilities: " & $strPowerManagementCapabilities & @CRLF
      $Output &= "PowerManagementSupported: " & $objItem.PowerManagementSupported & @CRLF
      $Output &= "Purpose: " & $objItem.Purpose & @CRLF
      $Output &= "QuotasEnabled: " & $objItem.QuotasEnabled & @CRLF
      $Output &= "QuotasIncomplete: " & $objItem.QuotasIncomplete & @CRLF
      $Output &= "QuotasRebuilding: " & $objItem.QuotasRebuilding & @CRLF
      $Output &= "SerialNumber: " & $objItem.SerialNumber & @CRLF
      $Output &= "Status: " & $objItem.Status & @CRLF
      $Output &= "StatusInfo: " & $objItem.StatusInfo & @CRLF
      $Output &= "SupportsDiskQuotas: " & $objItem.SupportsDiskQuotas & @CRLF
      $Output &= "SupportsFileBasedCompression: " & $objItem.SupportsFileBasedCompression & @CRLF
      $Output &= "SystemCreationClassName: " & $objItem.SystemCreationClassName & @CRLF
      $Output &= "SystemName: " & $objItem.SystemName & @CRLF
      $Output &= "SystemVolume: " & $objItem.SystemVolume & @CRLF
   Next
   ConsoleWrite($Output)
   FileWrite(@TempDir & "\Win32_Volume.TXT", $Output )
   Run(@Comspec & " /c start " & @TempDir & "\Win32_Volume.TXT" )
Else
   Msgbox(0,"WMI Output","No WMI Objects Found for class: " & "Win32_Volume" )
Endif


Func WMIDateStringToDate($dtmDate)

    Return (StringMid($dtmDate, 5, 2) & "/" & _
    StringMid($dtmDate, 7, 2) & "/" & StringLeft($dtmDate, 4) _
    & " " & StringMid($dtmDate, 9, 2) & ":" & StringMid($dtmDate, 11, 2) & ":" & StringMid($dtmDate,13, 2))
EndFunc

I hope that now i really helped ;)

Cheers m8

Edited by November

Old Scriptology

Visual Ping 1.8 - Mass Ping Program with export to txt delimited.

Desktop 2 RGB and YMCK - Pick a color in the desktop and get the RGB and YMCK code.

Desktop 2 RGB - Pick a color in the desktop and get the RGB code.

ShootIT 1.0 - Screen Capture full and partial screen

[font="'Arial Black';"]Remember Remember The Fifth of November.[/font]

Share this post


Link to post
Share on other sites

Hi again

Use Win32_Volume :)

Ah. That one isn't offered within Scriptomatic.

But with this one here, you pointed me to

#cs
class Win32_Volume : CIM_StorageVolume
{
  uint16 Access;
  uint16 Availability;
  uint64 BlockSize;
  string Caption;
  uint32 ConfigManagerErrorCode;
  boolean ConfigManagerUserConfig;
  string CreationClassName;
  string Description;
  boolean ErrorCleared;
  string ErrorDescription;
  string ErrorMethodology;
  datetime InstallDate;
  uint32 LastErrorCode;
  string Name;
  uint64 NumberOfBlocks;
  string PNPDeviceID;
  uint16[] PowerManagementCapabilities;
  boolean PowerManagementSupported;
  string Purpose;
  string [b][color="#FF0000"]Status;[/color][/b]
  uint16 StatusInfo;
  string SystemCreationClassName;
  string SystemName;
  string DeviceID;
  uint64 Capacity;
  boolean Compressed;
  string [b][color="#FF0000"]DriveLetter;[/color][/b]
  uint32 DriveType;
  string FileSystem;
  uint64 FreeSpace;
  boolean IndexingEnabled;
  boolean DirtyBitSet;
  string [b][color="#FF0000"]Label;[/color][/b]
  uint32 MaximumFileNameLength;
  boolean Automount;
  boolean QuotasEnabled;
  boolean QuotasIncomplete;
  boolean QuotasRebuilding;
  uint32 [b][color="#FF0000"]SerialNumber;[/color][/b]
  boolean SupportsDiskQuotas;
  boolean SupportsFileBasedCompression;
};
#ce

... I propalbly can work it out :)

I hope that now i really helped o:)

I think (hope...) so ;)

Thanks, Rudi.


Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

[Edit]

I had to fail. Well, at least I had some excercises :mad:

Win32_Volume Class

The Win32_Volume class represents an area of storage on a hard disk. The class returns local volumes that are formatted, unformatted, mounted, or offline. A volume is formatted by using a file system, such as FAT or NTFS, and might have a drive letter assigned to it. One hard disk can have multiple volumes, and volumes can span multiple physical disks. The Win32_Volume class does not support disk drive management.

Windows XP and earlier:  This class is not available.

Any furter Ideas for the WMI blind person? ;)

Regards, Rudi.

[/Edit]

Hi again, unfortunately I fail:

Win32_Volume isn't offerd in Scriptomatic. So this is, how I tried to get out all the stuff described here:

On Error Resume Next
Const wbemFlagReturnImmediately = &h10
Const wbemFlagForwardOnly = &h20

arrComputers = Array("PC4-006")
For Each strComputer In arrComputers
    WScript.Echo
    WScript.Echo "=========================================="
    WScript.Echo "Computer: " & strComputer
    WScript.Echo "=========================================="

    Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
    Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_Volume", "WQL", _
            wbemFlagReturnImmediately + wbemFlagForwardOnly)

    For Each objItem In colItems
        WScript.Echo "Access: " & objItem.Access
        WScript.Echo "Availability: " & objItem.Availability
        WScript.Echo "BlockSize: " & objItem.BlockSize
        WScript.Echo "Caption: " & objItem.Caption
        WScript.Echo "ConfigManagerErrorCode: " & objItem.ConfigManagerErrorCode
        WScript.Echo "ConfigManagerUserConfig: " & objItem.ConfigManagerUserConfig
        WScript.Echo "CreationClassName: " & objItem.CreationClassName
        WScript.Echo "Description: " & objItem.Description
        WScript.Echo "ErrorCleared: " & objItem.ErrorCleared
        WScript.Echo "ErrorDescription: " & objItem.ErrorDescription
        WScript.Echo "ErrorMethodology: " & objItem.ErrorMethodology
        WScript.Echo "InstallDate: " & objItem.InstallDate
        WScript.Echo "LastErrorCode: " & objItem.LastErrorCode
        WScript.Echo "Name: " & objItem.Name
        WScript.Echo "NumberOfBlocks: " & objItem.NumberOfBlocks
        WScript.Echo "PNPDeviceID: " & objItem.PNPDeviceID
        WScript.Echo "PowerManagementCapabilities: " & objItem.PowerManagementCapabilities
        WScript.Echo "PowerManagementSupported: " & objItem.PowerManagementSupported
        WScript.Echo "Purpose: " & objItem.Purpose
        WScript.Echo "Status: " & objItem.Status
        WScript.Echo "StatusInfo: " & objItem.StatusInfo
        WScript.Echo "SystemCreationClassName: " & objItem.SystemCreationClassName
        WScript.Echo "SystemName: " & objItem.SystemName
        WScript.Echo "DeviceID: " & objItem.DeviceID
        WScript.Echo "Capacity: " & objItem.Capacity
        WScript.Echo "Compressed: " & objItem.Compressed
        WScript.Echo "DriveLetter: " & objItem.DriveLetter
        WScript.Echo "DriveType: " & objItem.DriveType
        WScript.Echo "FileSystem: " & objItem.FileSystem
        WScript.Echo "FreeSpace: " & objItem.FreeSpace
        WScript.Echo "IndexingEnabled: " & objItem.IndexingEnabled
        WScript.Echo "DirtyBitSet: " & objItem.DirtyBitSet
        WScript.Echo "Label: " & objItem.Label
        WScript.Echo "MaximumFileNameLength: " & objItem.MaximumFileNameLength
        WScript.Echo "Automount: " & objItem.Automount
        WScript.Echo "QuotasEnabled: " & objItem.QuotasEnabled
        WScript.Echo "QuotasIncomplete: " & objItem.QuotasIncomplete
        WScript.Echo "QuotasRebuilding: " & objItem.QuotasRebuilding
        WScript.Echo "SerialNumber: " & objItem.SerialNumber
        WScript.Echo "SupportsDiskQuotas: " & objItem.SupportsDiskQuotas
        WScript.Echo "SupportsFileBasedCompression: " & objItem.SupportsFileBasedCompression
    Next
Next
Function WMIDateStringToDate(dtmDate)
WScript.Echo dtm:
WMIDateStringToDate = CDate(Mid(dtmDate, 5, 2) & "/" & _
        Mid(dtmDate, 7, 2) & "/" & Left(dtmDate, 4) _
         & " " & Mid(dtmDate, 9, 2) & ":" & Mid(dtmDate, 11, 2) & ":" & Mid(dtmDate, 13, 2))
End Function

Well, it doesn't return any information from the ObjItem. Doesn't matter, whether I run it as VBS or copy/paste it over to scriptomatc. I cannot find, why. o:)

Anyways, I learned something about WMI. And hopefully, with some further help from YOU :) I'll finally make it to do what I want. :)

Regards, Rudi.

Edited by rudi

Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Share this post


Link to post
Share on other sites

Witch O.S. are you running? Win XP?

As far as i understand Win32_Volume Class it´s a Win Vista class.

Your script is a script that outputs the name of all removable disks in a computer right?

If disk f: = removable then

output f:

If disk g= fixed

no output

... and so on

The only issue here is that you don't want to mix removable (pen drives) with other removables (floppys) right?


Old Scriptology

Visual Ping 1.8 - Mass Ping Program with export to txt delimited.

Desktop 2 RGB and YMCK - Pick a color in the desktop and get the RGB and YMCK code.

Desktop 2 RGB - Pick a color in the desktop and get the RGB code.

ShootIT 1.0 - Screen Capture full and partial screen

[font="'Arial Black';"]Remember Remember The Fifth of November.[/font]

Share this post


Link to post
Share on other sites

Hi.

My OS is XP, right.

[snip]

The only issue here is that you don't want to mix removable (pen drives) with other removables (floppys) right?

Exactly!

And I'd like to know, whether externally connected USB HDDs are *ALWAYS* listed as "fixed", or if (certain conditions) they might show up as removable as well: As they *ARE* removable, aren't they?

So will a 'DriveGetDrive("removable")' recognize *ONLY* floppies and thumbdrives? Then I could be happy with a 2nd step size check: If it's above 2.88MB, it's a thumb drive.

What about ZIP drives and similar stuff?

To check through this mighty WMI example page you pointed me to I wrote this one:

#include <array.au3>

$Dir = "C:\MyWmiFirstSteps"
$InputFile=$dir & "\input.txt"
If Not FileExists($InputFile) Then InfoBox()

$info = Einlesen($InputFile)



$Class = $info[1]

#region Header
$Header = 'On Error Resume Next' & @CRLF & _
        'Const wbemFlagReturnImmediately = &h10' & @CRLF & _
        'Const wbemFlagForwardOnly = &h20' & @CRLF & _
        @CRLF & _
        'arrComputers = Array("' & @ComputerName & '")' & @CRLF & _
        'For Each strComputer In arrComputers' & @CRLF & _
        '   WScript.Echo' & @CRLF & _
        '   WScript.Echo "=========================================="' & @CRLF & _
        '   WScript.Echo "Computer          : " & strComputer' & @CRLF & _
        '   WScript.Echo "=========================================="' & @CRLF & _
        '   WScript.Echo "Class investigated: ' & $Class &'"' & @CRLF & _
        '   WScript.Echo "=========================================="' & @CRLF & _
        @CRLF & _
        '   Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")' & @CRLF & _
        '   Set colItems = objWMIService.ExecQuery("SELECT * FROM ' & $Class & '", "WQL", _' & @CRLF & _
        '                                          wbemFlagReturnImmediately + wbemFlagForwardOnly)' & @CRLF & _
        @CRLF & _
        '   For Each objItem In colItems'
#endregion Header

#region Footer
$Footer = 'Function WMIDateStringToDate(dtmDate)' & @CRLF & _
        'WScript.Echo dtm: ' & @CRLF & _
        '   WMIDateStringToDate = CDate(Mid(dtmDate, 5, 2) & "/" & _' & @CRLF & _
        '   Mid(dtmDate, 7, 2) & "/" & Left(dtmDate, 4) _' & @CRLF & _
        '   & " " & Mid (dtmDate, 9, 2) & ":" & Mid(dtmDate, 11, 2) & ":" & Mid(dtmDate,13, 2))' & @CRLF & _
        'End Function' & @CRLF
#endregion Footer
WriteCode($Class) ;Name mit übergeben.


Func WriteCode($name)
    DirCreate($Dir)
    $file = $Dir & "\" & $name & ".VBS"
    $handle = FileOpen($file, 2)
    FileWriteLine($handle, $Header)
    For $i = 2 To $info[0]
        FileWriteLine($handle, @TAB & @TAB & 'WScript.Echo "' & $info[$i] & ': " & objItem.' & $info[$i])
    Next
    FileWriteLine($handle, @TAB & "Next")
    FileWriteLine($handle, "Next")
    FileWriteLine($handle, $Footer)
    FileClose($handle)
    Run("notepad " & $file)
EndFunc   ;==>WriteCode


Func Einlesen($file)
    Local $ClassObjArr[1]
    Local $dummy
    $handle = FileOpen($file, 0)
    $dummy = FileReadLine($handle)
    ConsoleWrite($dummy & @CRLF)
    $tempArr = StringRegExp($dummy, "\A\S+\s+(\S+).*", 3)
    _ArrayAdd($ClassObjArr, $tempArr[0])
    While 1
        $dummy = FileReadLine($handle)
        If $dummy = "{" Then ContinueLoop ; throw away this line: Opening bracket.
        If $dummy = "};" Then ExitLoop ; that's the final line.
        If @error Then
            ConsoleWrite("Fertig" & @CRLF)
            ExitLoop
        EndIf
        $tempArr = StringRegExp($dummy, "\s.*\s(.*);", 3)
        If IsArray($tempArr) Then
            _ArrayAdd($ClassObjArr, $tempArr[0])
        Else
            MsgBox(0, "TempArr", $tempArr)
        EndIf

    WEnd
    $ClassObjArr[0] = UBound($ClassObjArr) - 1
    ; _ArrayDisplay($ClassObjArr)
    Return $ClassObjArr
EndFunc   ;==>Einlesen

Func InfoBox()
    MsgBox(0, "Info", "This Script will convert WMI descriptions into VBS scripts," & @lf & _
            "those can be tested using Scriptomatic from Microsoft. (use plain text output there)" & @LF & @LF & _
            "Expected Input file: " & $InputFile & @lf & @LF & @LF & _
            "One Example: http://msdn.microsoft.com/en-us/library/aa394084(VS.85).aspx" & @LF & _
            @LF & _
            "class Win32_AccountSID" & @LF & _
            "{" & @LF & _
            " Win32_Account REF Element;" & @LF & _
            " Win32_SID REF Setting;" & @LF & _
            "};" & @lf & @lf & _
            "The resulting VBS code will be written to a file in that folder, named ""CLASS.VBS"" " & @LF & _
            "for this example, and finally that file is opened using Notepad.")
    Exit
EndFunc   ;==>Info

After I was done, :) I reallized, that I should have done this to create an AU3 output. Well, maybe next week. :)

Regards, Rudi.


Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Share this post


Link to post
Share on other sites

Bump.

Pls. let me ask once more about the media type "removable":

- How to distinguish USB thumb drives from Floppy / ZIP and similar types?

- are HDDs connected to external USB ports *ALWAYS* listed as "fixed"? I've tried several HDDs connected that way, up to now all of them were listed as drive type = fixed, even though they *ARE* removable - aren't they?

Maybe some WMI stuff could help me to work that out. Win32_Volume Class it´s a Win Vista class, so that one doesn't help me...

Any suggestions appreciated, especally pointing towards documentation I could go through.

TIA.

Regards, Rudi.


Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

As far as I know this comes down to the actual usb interface on the device.

Some of them register as removable some fixed, just depends on what identifier is programmed into.

It looks like some of the code above let you pull the parameters for the device.

Try doing a using StringInStr() on the PNPDeviceID (sometimes called just plain deviceID) to find "USB"

That's basically the path to the device as I understand it. So no matter what the device class the device should contain USB.

I'll try a few of my usb gadgets later, if I can find one that shows up as a fixed disk I'll verify that.

Kenny

Edited by ken82m

My Contributions _StringMultiReplace PC Builders Console - Secure PDF Creator - Cisco VPN Installer MS DNS Server Backup Script - MS DHCP Backup Script IT Admin Console - Toggle Admin Mode - MyMovies-Add Discs Script - IT Help Desk and System Information Tool - Set On Lid Close Power Option - Streaming Media Server & Website "I believe that when we leave a place, part of it goes with us and part of us remains... Go anywhere, when it is quiet, and just listen.. After a while, you will hear the echoes of all our conversations, every thought and word we've exchanged.... Long after we are gone our voices will linger in these walls for as long as this place remains."

Share this post


Link to post
Share on other sites

You might want to download "devcon" from microsoft. It might be useful for troubleshooting.

It can pull the device info for you too.

-Kenny


My Contributions _StringMultiReplace PC Builders Console - Secure PDF Creator - Cisco VPN Installer MS DNS Server Backup Script - MS DHCP Backup Script IT Admin Console - Toggle Admin Mode - MyMovies-Add Discs Script - IT Help Desk and System Information Tool - Set On Lid Close Power Option - Streaming Media Server & Website "I believe that when we leave a place, part of it goes with us and part of us remains... Go anywhere, when it is quiet, and just listen.. After a while, you will hear the echoes of all our conversations, every thought and word we've exchanged.... Long after we are gone our voices will linger in these walls for as long as this place remains."

Share this post


Link to post
Share on other sites

Hi all.

Thanks for your help!

Slowly I get familiar with WMI :)

After checking several USB HDDs and USB Tumb Drives it looks like that "InterfaceType" and "MediaType" are sufficent, to distinguish USB thumb drives / USB HDDs / vs. IDE+SATA HDDs. So far I had no chance to check how eSATA drives are classified.

Const $wbemFlagReturnImmediately = 0x10
Const $wbemFlagForwardOnly = 0x20

$objWMIService = ObjGet("winmgmts:\\" & @ComputerName & "\root\CIMV2")
$colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_DiskDrive", "WQL", _
        $wbemFlagReturnImmediately + $wbemFlagForwardOnly)

For $objItem In $colItems
    ConsoleWrite(" ----- next Device -----------" & @CRLF)
    ConsoleWrite("InterfaceType: " & $objItem.InterfaceType & @CRLF)
    ConsoleWrite("MediaType: " & $objItem.MediaType & @CRLF)
    ConsoleWrite("Caption: " & $objItem.Caption & @CRLF)
    ConsoleWrite("MediaLoaded: " & $objItem.MediaLoaded & @CRLF)
    ConsoleWrite("Model: " & $objItem.Model & @CRLF)
    ConsoleWrite("Name: " & $objItem.Name & @CRLF)
    ConsoleWrite("NeedsCleaning: " & $objItem.NeedsCleaning & @CRLF)
    ConsoleWrite("NumberOfMediaSupported: " & $objItem.NumberOfMediaSupported & @CRLF)
    ConsoleWrite("Partitions: " & $objItem.Partitions & @CRLF)
    ConsoleWrite("PNPDeviceID: " & $objItem.PNPDeviceID & @CRLF)
    ConsoleWrite("SectorsPerTrack: " & $objItem.SectorsPerTrack & @CRLF)
    ConsoleWrite("Signature: " & $objItem.Signature & @CRLF)
    ConsoleWrite("Size: " & $objItem.Size & @CRLF)
    ConsoleWrite("Status: " & $objItem.Status & @CRLF)
    ConsoleWrite("StatusInfo: " & $objItem.StatusInfo & @CRLF)
    ConsoleWrite("SystemCreationClassName: " & $objItem.SystemCreationClassName & @CRLF)
    ConsoleWrite("SystemName: " & $objItem.SystemName & @CRLF)
    ConsoleWrite("TotalCylinders: " & $objItem.TotalCylinders & @CRLF)
    ConsoleWrite("TotalHeads: " & $objItem.TotalHeads & @CRLF)
    ConsoleWrite("TotalSectors: " & $objItem.TotalSectors & @CRLF)
    ConsoleWrite("TotalTracks: " & $objItem.TotalTracks & @CRLF)
    ConsoleWrite("TracksPerCylinder: " & $objItem.TracksPerCylinder & @CRLF)
    ConsoleWrite(@CRLF & @CRLF)
Next

A typical output for a thumb drive looks like this:

InterfaceType: USB
MediaType: Removable media other than   floppy
Caption: takeMS USB Mini USB Device
MediaLoaded: -1
Model: takeMS USB Mini USB Device
Name: \\.\PHYSICALDRIVE3
NeedsCleaning: 
NumberOfMediaSupported: 
Partitions: 1
PNPDeviceID: USBSTOR\DISK&VEN_TAKEMS&PROD_USB_MINI&REV_1100\AA04012700007427&0
SectorsPerTrack: 63
Signature: -1022939624
Size: 1003484160
Status: OK
StatusInfo: 
SystemCreationClassName: Win32_ComputerSystem
SystemName: PC02
TotalCylinders: 122
TotalHeads: 255
TotalSectors: 1959930
TotalTracks: 31110
TracksPerCylinder: 255

But howto get the relation of the information retrieved with that code to the drive letters or mount points? :)

Regards, Rudi.


Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0