deviantp Posted May 4, 2013 Share Posted May 4, 2013 Hey AutoIT forums! I recently started a project in Batch to detect paritions and if configs are in a certain state, automatically partition the drive using disk part. The script works well, but with a few flaws involving drive size in bytes and batch no being able to handle numbers that large, so with recommendation from a friend I fired up AutoIT! With batch I was using WMIC (LogicalDisk and DiskDrive) to get info, however there's no way of tying those two outcomes together, IE no common ground to reference what physical disk contains which partitions.. I'm very against being spoon fed code, so was wondering if anyone had any experience or ideas on how this could be done. The ideal outcome would be add the active paritions on a physical disk into the 3d array I've constructed! Any help much apprecaited -Martin Link to comment Share on other sites More sharing options...
KaFu Posted May 4, 2013 Share Posted May 4, 2013 (edited) This might help ... Edited May 4, 2013 by KaFu OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
mikell Posted May 4, 2013 Share Posted May 4, 2013 (edited) Maybe the func used in this script can be helpfulexpandcollapse popup#include <GUIConstantsEx.au3> ;#include <Array.au3> #include <ListviewConstants.au3> SplashTextOn ("", "Loading...", 180, 60, -1, -1, 49) Global $var = DriveGetDrive("FIXED") $myinfos = _GetDriveInfos() ;_arraydisplay($myinfos) $W = 610 $Ypos = 45+(14*$var[0]) $Main = GuiCreate("Disques", $W+260, $Ypos) $listview = GUICtrlCreateListView("Volume|Nom|Taille (Go)|Disponible (Go)|Occupé (Go)|" & _ "Plein à|Libre (Go)|Disque physique|ID", 10, 5, $W+240, $Ypos-15) For $i = 0 to $var[0]-1 $percentocc = Round(($myinfos[$i][2]-$myinfos[$i][3])*100/$myinfos[$i][2], 1) GUICtrlCreateListViewItem(StringUpper($myinfos[$i][0]) &"|"& $myinfos[$i][6] &"|"& _ $myinfos[$i][4] &"|"& $myinfos[$i][2] &"|"& $myinfos[$i][2]-$myinfos[$i][3] &"|"& _ $percentocc &" %" &"|"& $myinfos[$i][3] &"|"& $myinfos[$i][1] &"|"& $myinfos[$i][5], $listview) Next GUICtrlSendMsg($listview, $LVM_SETCOLUMNWIDTH, 0, 60) GUICtrlSendMsg($listview, $LVM_SETCOLUMNWIDTH, 1, 110) GUICtrlSendMsg($listview, $LVM_SETCOLUMNWIDTH, 2, 70) GUICtrlSendMsg($listview, $LVM_SETCOLUMNWIDTH, 3, 90) GUICtrlSendMsg($listview, $LVM_SETCOLUMNWIDTH, 4, 80) GUICtrlSendMsg($listview, $LVM_SETCOLUMNWIDTH, 5, 70) GUICtrlSendMsg($listview, $LVM_SETCOLUMNWIDTH, 6, 70) GUICtrlSendMsg($listview, $LVM_SETCOLUMNWIDTH, 7, 170) GUICtrlSendMsg($listview, $LVM_SETCOLUMNWIDTH, 8, 120) GUISetState() SplashOff() While GUIGetMsg()<>$GUI_EVENT_CLOSE Sleep(10) WEnd ;====================================== Func _GetDriveInfos() Dim $specifs[$var[0]][7] For $i = 1 to $var[0] Dim $Services = ObjGet('winmgmts:\\.\root\cimv2') Dim $DiskDrives = $Services.ExecQuery("Select Caption, DeviceID From Win32_DiskDrive") For $DiskDrive In $DiskDrives Dim $DiskPartitions = $Services.ExecQuery("Associators of {Win32_DiskDrive.DeviceID='" & _ $DiskDrive.DeviceID & "'} Where AssocClass = Win32_DiskDriveToDiskPartition") For $DiskPartition In $DiskPartitions Dim $LogicalDisks = $Services.ExecQuery ("Associators of {Win32_DiskPartition.DeviceID='" & _ $DiskPartition.DeviceID & "'} Where AssocClass = Win32_LogicalDiskToPartition") For $LogicalDisk In $LogicalDisks If $LogicalDisk.DeviceID = $var[$i] Then $specifs[$i-1][0] = $var[$i] $specifs[$i-1][1] = $DiskDrive.Caption $specifs[$i-1][2] = Round(DriveSpaceTotal($var[$i])/1000 ) $specifs[$i-1][3] = Round(DriveSpaceFree($var[$i])/1000 ) $specifs[$i-1][4] = Round($LogicalDisk.Size/1000000000) $specifs[$i-1][5] = $DiskPartition.DeviceID $specifs[$i-1][6] = $LogicalDisk.VolumeName EndIf Next Next Next Next Return $specifs EndFuncand the UDF scriptomatic.au3 to get more infos Edited May 4, 2013 by mikell ahmeddzcom 1 Link to comment Share on other sites More sharing options...
deviantp Posted May 4, 2013 Author Share Posted May 4, 2013 These are perfect! Thanks very much for your replies, I've done some adapting and have it all working as I need, thanks very much and am now convined AutoIT might get a lot more use in the near future! Cheers guys! 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