caveman0 Posted November 13, 2008 Share Posted November 13, 2008 Hi, I'm trying to create an Auto-IT script that when given a drive letter the program will find out what disk number it is on. (e.g: Drive C: is on Disk 0). I've been trying to look at WMI to see if I can get it but i can't find a function that will help me with what I need. Thanks. Link to comment Share on other sites More sharing options...
spudw2k Posted November 13, 2008 Share Posted November 13, 2008 (edited) Here's an example using WMI. #include <Array.au3> $arrResults=_GetLogicalDriveToPartition() _ArrayDisplay($arrResults) Func _GetLogicalDriveToPartition() $objWMIService = ObjGet("winmgmts:{impersonationLevel=Impersonate}!\\.\root\cimv2") If Not IsObj($objWMIService) Then Return -1 ;Failed to Connect to WMI on Local Machine Local $arr[1][2] $colDevice = $objWMIService.ExecQuery("SELECT * from Win32_LogicalDiskToPartition") For $objItem in $colDevice ReDim $arr[UBound($arr)+1][2] $arr[UBound($arr)-1][0]=StringTrimLeft($objItem.Antecedent,StringInStr($objItem.Antecedent,"=",0,-1)) $arr[UBound($arr)-1][1]=StringTrimLeft($objItem.Dependent,StringInstr($objItem.Dependent,"=",0,-1)) Next $colDevice=0 $objWMIService=0 $arr[0][0]="Disk #, Partition #" $arr[0][1]="Drive Letter" Return $arr EndFunc Edited November 13, 2008 by spudw2k 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