-
Notifications
You must be signed in to change notification settings - Fork 73
/
Copy pathEnumDiskDrives.ahk
29 lines (27 loc) · 1.06 KB
/
EnumDiskDrives.ahk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/*
Enumera todos los discos y sus particiones.
Return:
Devuelve un objeto, la clave es el número que identifica al disco, y el valor es un array con la letra de la partición.
Ejemplo:
For Disk, Partitions in EnumDiskDrives()
{
Str .= Disk . '`n'
For Each, Partition in Partitions
Str .= '`t' . Partition . '`n'
Str .= '`n'
}
MsgBox(Str)
*/
EnumDiskDrives()
{
Local n, Disk
, List := {}
For Obj in ComObjGet('winmgmts:\\.\root\CIMV2').ExecQuery('SELECT * FROM Win32_LogicalDiskToPartition')
{
Disk := SubStr(Obj.Antecedent, n:=InStr(Obj.Antecedent, 'Disk #')+6, InStr(Obj.Antecedent, ',')-n)
If (!List.HasKey(Disk))
List[Disk] := []
List[Disk][StrReplace(SubStr(Obj.Antecedent, n:=InStr(Obj.Antecedent, 'Partition #')+11, 3), '"')] := SubStr(Obj.Dependent, n:=InStr(Obj.Dependent, '="')+2, InStr(Obj.Dependent, ':"')-n)
}
Return (List)
} ;https://autohotkey.com/board/topic/89345-physical-hard-drive-information/