Danny35d Posted August 22, 2006 Share Posted August 22, 2006 I try to used DriveGetType ( "path" ) and check for "Removable" value but, when I plug my 60 Gb usb hard disk in some computer detected as "Removable" on others detected as "Fixed". Anybody knows a way to check if is a local hard disk or an attach usb hard disk. AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line Link to comment Share on other sites More sharing options...
GaryFrost Posted August 22, 2006 Share Posted August 22, 2006 (edited) Win32_DiskDrive InterfaceType expandcollapse popup; Generated by AutoIt Scriptomatic $wbemFlagReturnImmediately = 0x10 $wbemFlagForwardOnly = 0x20 $colItems = "" $strComputer = "localhost" $Output="" $Output = $Output & "Computer: " & $strComputer & @CRLF $Output = $Output & "==========================================" & @CRLF $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_DiskDrive", "WQL", _ $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) then For $objItem In $colItems ;~ $Output = $Output & "Availability: " & $objItem.Availability & @CRLF $Output = $Output & "BytesPerSector: " & $objItem.BytesPerSector & @CRLF $strCapabilities = $objItem.Capabilities(0) $Output = $Output & "Capabilities: " & $strCapabilities & @CRLF $strCapabilityDescriptions = $objItem.CapabilityDescriptions(0) $Output = $Output & "CapabilityDescriptions: " & $strCapabilityDescriptions & @CRLF $Output = $Output & "Caption: " & $objItem.Caption & @CRLF ;~ $Output = $Output & "CompressionMethod: " & $objItem.CompressionMethod & @CRLF ;~ $Output = $Output & "ConfigManagerErrorCode: " & $objItem.ConfigManagerErrorCode & @CRLF ;~ $Output = $Output & "ConfigManagerUserConfig: " & $objItem.ConfigManagerUserConfig & @CRLF ;~ $Output = $Output & "CreationClassName: " & $objItem.CreationClassName & @CRLF ;~ $Output = $Output & "DefaultBlockSize: " & $objItem.DefaultBlockSize & @CRLF $Output = $Output & "Description: " & $objItem.Description & @CRLF $Output = $Output & "DeviceID: " & $objItem.DeviceID & @CRLF ;~ $Output = $Output & "ErrorCleared: " & $objItem.ErrorCleared & @CRLF ;~ $Output = $Output & "ErrorDescription: " & $objItem.ErrorDescription & @CRLF ;~ $Output = $Output & "ErrorMethodology: " & $objItem.ErrorMethodology & @CRLF ;~ $Output = $Output & "Index: " & $objItem.Index & @CRLF ;~ $Output = $Output & "InstallDate: " & WMIDateStringToDate($objItem.InstallDate) & @CRLF $Output = $Output & "InterfaceType: " & $objItem.InterfaceType & @CRLF ;~ $Output = $Output & "LastErrorCode: " & $objItem.LastErrorCode & @CRLF $Output = $Output & "Manufacturer: " & $objItem.Manufacturer & @CRLF ;~ $Output = $Output & "MaxBlockSize: " & $objItem.MaxBlockSize & @CRLF ;~ $Output = $Output & "MaxMediaSize: " & $objItem.MaxMediaSize & @CRLF $Output = $Output & "MediaLoaded: " & $objItem.MediaLoaded & @CRLF $Output = $Output & "MediaType: " & $objItem.MediaType & @CRLF ;~ $Output = $Output & "MinBlockSize: " & $objItem.MinBlockSize & @CRLF $Output = $Output & "Model: " & $objItem.Model & @CRLF $Output = $Output & "Name: " & $objItem.Name & @CRLF ;~ $Output = $Output & "NeedsCleaning: " & $objItem.NeedsCleaning & @CRLF ;~ $Output = $Output & "NumberOfMediaSupported: " & $objItem.NumberOfMediaSupported & @CRLF $Output = $Output & "Partitions: " & $objItem.Partitions & @CRLF ;~ $Output = $Output & "PNPDeviceID: " & $objItem.PNPDeviceID & @CRLF ;~ $strPowerManagementCapabilities = $objItem.PowerManagementCapabilities(0) ;~ $Output = $Output & "PowerManagementCapabilities: " & $strPowerManagementCapabilities & @CRLF ;~ $Output = $Output & "PowerManagementSupported: " & $objItem.PowerManagementSupported & @CRLF ;~ $Output = $Output & "SCSIBus: " & $objItem.SCSIBus & @CRLF ;~ $Output = $Output & "SCSILogicalUnit: " & $objItem.SCSILogicalUnit & @CRLF ;~ $Output = $Output & "SCSIPort: " & $objItem.SCSIPort & @CRLF ;~ $Output = $Output & "SCSITargetId: " & $objItem.SCSITargetId & @CRLF $Output = $Output & "SectorsPerTrack: " & $objItem.SectorsPerTrack & @CRLF $Output = $Output & "Signature: " & $objItem.Signature & @CRLF $Output = $Output & "Size: " & $objItem.Size & @CRLF $Output = $Output & "Status: " & $objItem.Status & @CRLF ;~ $Output = $Output & "StatusInfo: " & $objItem.StatusInfo & @CRLF ;~ $Output = $Output & "SystemCreationClassName: " & $objItem.SystemCreationClassName & @CRLF $Output = $Output & "SystemName: " & $objItem.SystemName & @CRLF $Output = $Output & "TotalCylinders: " & $objItem.TotalCylinders & @CRLF $Output = $Output & "TotalHeads: " & $objItem.TotalHeads & @CRLF $Output = $Output & "TotalSectors: " & $objItem.TotalSectors & @CRLF $Output = $Output & "TotalTracks: " & $objItem.TotalTracks & @CRLF $Output = $Output & "TracksPerCylinder: " & $objItem.TracksPerCylinder & @CRLF if Msgbox(1,"WMI Output",$Output) = 2 then ExitLoop $Output="" Next Else Msgbox(0,"WMI Output","No WMI Objects Found for class: " & "Win32_DiskDrive" ) 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 Edited August 22, 2006 by gafrost SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
Danny35d Posted August 22, 2006 Author Share Posted August 22, 2006 InterfaceTypeThanks a lot. This is the second time that your SAVE me. Next time that I'm doing training in Tennessee I will buy you a beer... AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line Link to comment Share on other sites More sharing options...
sshrum Posted August 22, 2006 Share Posted August 22, 2006 (edited) I ran into the same problem (removable/fixed) with USB drives. I couda used this info a year ago. Then again I shoulda asked. Edited August 22, 2006 by sshrum Sean Shrum :: http://www.shrum.net All my published AU3-based apps and utilities 'Make it idiot-proof, and someone will make a better idiot' Link to comment Share on other sites More sharing options...
Pieter Posted August 23, 2006 Share Posted August 23, 2006 (edited) ... or you could place an .ini file in the root of the drive and do this:If FileExists("D:\MyIni.ini") Then $drivemounted = "yes" EndIfAdditionaly, you can insert a unique string in that file to be able to seperate the drive from others. In that case, you need to do something like this:If FileExists("D:\MyIni.ini") Then $unique_id = IniRead("D:\MyIni.ini", "general", "unique_id", "error") If $unique_id = "fsg651g" Then $drivemounted = "yes" ElseIf $unique_id = "error" Then MsgBox(0,"Error","Error, ID not defined!") $drivemounted = "no" Else $drivemounted = "no" EndIf EndIf Edited August 23, 2006 by Pieter iPod + Online calendars = iPodCALsync 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