rlemoine002 Posted October 14, 2016 Share Posted October 14, 2016 I am looking for a way to use Autoit to do the clean,create primary partition, format, etc that is normally done in Diskpart. The trick is that I am using a hub that holds 20 USB flashdrives, AND when the selection to pick the disk is done, to disregard the 2 local hard drives in the PC so they don't get wiped out. I have searched and tried various things without success. does anybody have any ideas? Thank you. Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted October 14, 2016 Moderators Share Posted October 14, 2016 So, let's start with identifying the drives by type. Does this return all 20 drives as you would expect? And if so, what do they show up as (mass storage device, composite device, etc)? $oWMI = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2") $aOS = $oWMI.ExecQuery("Select * from Win32_USBHub") For $sItem In $aOS $sDevID = $sItem.DeviceID & ":" & @CRLF $sPNPID = " " & $sItem.PNPDeviceID & @CRLF $sDesc = " " & $sItem.Description & @CRLF $sName = " " & $sItem.Name & @CRLF ConsoleWrite($sDevID & $sDesc & $sPNPID & $sName & @CRLF) Next "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
rlemoine002 Posted October 14, 2016 Author Share Posted October 14, 2016 Hi JLogan. Yes the flash drives are shown as mass storage device, but everything usb in the PC shows up also such as hubs, printing support (usb printer). Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted October 14, 2016 Moderators Share Posted October 14, 2016 Right, which means you will need to narrow your search, something like this: Local $oWMI, $oUSB, $sDevID, $sPNPID, $sDesc, $sName $oWMI = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2") $oUSB = $oWMI.ExecQuery("Select * from Win32_USBHub") For $sItem In $oUSB If StringInStr($sItem.Name, "Mass Storage") Then $sDevID = $sItem.DeviceID & ":" & @CRLF $sPNPID = " " & $sItem.PNPDeviceID & @CRLF $sDesc = " " & $sItem.Description & @CRLF $sName = " " & $sItem.Name & @CRLF ConsoleWrite($sDevID & $sDesc & $sPNPID & $sName & @CRLF) EndIf Next "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
spudw2k Posted October 14, 2016 Share Posted October 14, 2016 I believe the Win32_DiskDrive is also an appropriate class to query...(filter by InterfaceType=USB) $oWMI = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2") $oWMICol = $oWMI.ExecQuery("Select * from Win32_DiskDrive Where InterfaceType = 'USB'") For $oInstance In $oWMICol $sCaption = $oInstance.Caption & ":" & @CRLF $sPNPID = " " & $oInstance.PNPDeviceID & @CRLF $sDesc = " " & $oInstance.Description & @CRLF $sDevID = " " & $oInstance.DeviceID & @CRLF ConsoleWrite($sCaption & $sDesc & $sPNPID & $sDevID & @CRLF) Next Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX BuilderMisc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retreive SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose ArrayProjects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalcCool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
rlemoine002 Posted October 14, 2016 Author Share Posted October 14, 2016 Actually, the results I get from spudw2k are more in line with what I'm looking for. At the end of each flase drive "info" section, the line shows: \\.\PHYSICALDRIVEnumber. This number seems to correspond to the List Disk command from Diskpart. Is this correct? Thanks to both of you for helping. Link to comment Share on other sites More sharing options...
spudw2k Posted October 14, 2016 Share Posted October 14, 2016 It should, yes. Might want to double-check a known disk in diskmgmt.msc or diskpart. Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX BuilderMisc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retreive SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose ArrayProjects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalcCool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now