Skip to content

Commit e423b65

Browse files
authored
Merge pull request #23 from htcfreek/v1.3
merge v1.3
2 parents ea6094c + 901a7a5 commit e423b65

2 files changed

Lines changed: 40 additions & 38 deletions

File tree

src/GetDiskInfoFromWmi/GetDiskInfoFromWmi.au3

Lines changed: 38 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77

88
#cs
99
===============================================================================================================================
10-
Title ...............: _GetDiskInfoFromWmi (GitHub: - https://github.com/htcfreek/AutoIt-Scripts)
11-
Version .............: 1.3
10+
Title ...............: _GetDiskInfoFromWmi (GitHub: https://github.com/htcfreek/AutoIt-Scripts)
11+
Version .............: 1.4
1212
License .............: GNU LGPLv3
1313
AutoIt Version ......: 3.3.14.5+
1414
Language ............: English
@@ -20,24 +20,27 @@
2020
===============================================================================================================================
2121
2222
CHANGELOG:
23+
2021-07-05 (v1.4)
24+
Fix: Typos in script and example.
25+
2326
2021-07-04 (v1.3)
24-
Fixed: Typos
25-
Changed: Improved comments
26-
Changed: Disk property header renamed: WindowsRunningOnDisk (SystemRoot) -> WindowsRunningOnDisk (SystemDisk)
27-
Changed: Partition property header renamed: PartitionIsSystemRoot -> PartitionIsSystemDisk
28-
Add: DiskType filter
29-
Add: Constants
30-
Add: Required includes
31-
Add: Error handling
27+
Fix: Typos
28+
Change: Improved comments
29+
Change: Disk property header renamed: WindowsRunningOnDisk (SystemRoot) -> WindowsRunningOnDisk (SystemDisk)
30+
Change: Partition property header renamed: PartitionIsSystemRoot -> PartitionIsSystemDisk
31+
New: DiskType filter
32+
New: Constants
33+
New: Required includes
34+
New: Error handling
3235
3336
2021-07-02 (v1.2)
34-
Added: Disk properties Manufacturer, Interfacetype, Mediatype, Serialnumber, Status
35-
Added: Partition property: Filesystem
36-
Changed: Disk property header renamed: SystemIsBootedFromDisk -> WindowsRunningOnDisk (SystemRoot)
37-
Changed: Partition property header renamed: SystemIsBootedFromPartition -> PartitionIsSystemRoot
37+
New: Disk properties Manufacturer, InterfaceType, MediaType, SerialNumber, Status
38+
New: Partition property: Filesystem
39+
Change: Disk property header renamed: SystemIsBootedFromDisk -> WindowsRunningOnDisk (SystemRoot)
40+
Change: Partition property header renamed: SystemIsBootedFromPartition -> PartitionIsSystemRoot
3841
3942
2021-07-02 (v1.0)
40-
Initial release
43+
New: Initial release
4144
4245
#ce
4346

@@ -57,27 +60,26 @@ Global Const $DiskInfoWmi_DiskType_Unknown = "Unknown%"
5760

5861
; Function
5962
; ---------
60-
6163
Func _GetDiskInfoFromWmi(ByRef $aDiskList, ByRef $aPartitionList, $bAddTableHeader = $DiskInfoWmi_TableHeader_Yes, $sFilterDiskType = $DiskInfoWmi_DiskType_All)
62-
; Name ...............: _GetDiskInfoFromWmi
64+
; Name ...............: _GetDiskInfoFromWmi
6365
; Author .............: htcfreek (Heiko) - https://github.com/htcfreek
64-
; Input parameter ....: ByRef $aDiskList = Array var for list of disks.
66+
; Input parameter ....: ByRef $aDiskList = Array var for list of disks.
6567
; ByRef $aPartitionList = Array var for list of partitions.
6668
; [$bAddTableHeader = $DiskInfoWmi_TableHeader_Yes] = Should array tables have a header row. (Values: 0|1 or $DiskInfoWmi_TableHeader_Yes|$DiskInfoWmi_TableHeader_No)
6769
; [$sFilterDiskType = $DiskInfoWmi_DiskType_All] = Which type of disk should be included in result. (Values: $DiskInfoWmi_DiskType_All|$DiskInfoWmi_DiskType_External|$DiskInfoWmi_DiskType_Removable|$DiskInfoWmi_DiskType_Fixed|$DiskInfoWmi_DiskType_Unknown)
68-
; Output parameter ...: none
70+
; Output parameter ...: none
6971
; On WMI-Error .......: @error = 1
70-
71-
72+
73+
7274
; Initialize function wide vars
7375
Local $aDisks[0][12]
7476
Local $aPartitions[0][13]
75-
Local $iDiskArrayCount = 0 ; Initialize counter to write some disk data later in correct array row.
76-
Local $iPartArrayCount = 0 ; Initialize counter to write partition data later in correct array row.
77+
Local $iDiskArrayCount = 0 ; Initialize counter to write some disk data later in correct array row.
78+
Local $iPartArrayCount = 0 ; Initialize counter to write partition data later in correct array row.
79+
7780

78-
7981
; Add Array header
80-
if ($bAddTableHeader = 1) Then
82+
if ($bAddTableHeader = 1) Then
8183
$sDiskHeader = "DiskNum" & "||" & "DiskDeviceID" & "||" & "DiskManufacturer" & "||" & "DiskModel" & "||" & "DiskInterfaceType" & "||" & "DiskMediaType" & "||" & "DiskSerialNumber" & "||" & "DiskState" & "||" & "DiskSize" & "||" & "DiskInitType" & "||" & "DiskPartitionCount" & "||" & "WindowsRunningOnDisk (SystemDrive)"
8284
_ArrayAdd($aDisks, $sDiskHeader, 0, "||")
8385
$sPartitionHeader = "DiskNum" & "||" & "PartitionNum" & "||" & "PartitionID" & "||" & "PartitionType" & "||" & "PartitionIsPrimary" & "||" & "PartitionIsBootPartition" & "||" & "PartitionLetter" & "||" & "PartitionLabel" & "||" & "PartitionFileSystem" & "||" & "PartitionSizeTotal" & "||" & "PartitionSizeUsed" & "||" & "PartitionSizeFree" & "||" & "PartitionIsSystemDrive"
@@ -96,22 +98,22 @@ Func _GetDiskInfoFromWmi(ByRef $aDiskList, ByRef $aPartitionList, $bAddTableHead
9698
Local $iDisk = $oDisk.Index
9799
Local $sNewDisk = $iDisk & "||" & $oDisk.DeviceID & "||" & $oDisk.Manufacturer & "||" & $oDisk.Model & "||" & $oDisk.InterfaceType & "||" & $oDisk.MediaType & "||" & $oDisk.SerialNumber & "||" & $oDisk.Status & "||" & $oDisk.Size & "||" & "<DiskInitStyle>" & "||" & $oDisk.Partitions & "||" & False
98100
_ArrayAdd($aDisks, $sNewDisk, 0, "||")
99-
101+
100102
; Get Partitions
101103
Local $oPartitions = $oWmiInstance.ExecQuery("ASSOCIATORS OF {Win32_DiskDrive.DeviceID='" & $oDisk.DeviceID & "'} WHERE AssocClass = Win32_DiskDriveToDiskPartition")
102104
For $oPartition In $oPartitions
103105
; Add Partition data to Array
104106
Local $iPartition = $oPartition.Index
105107
Local $sNewPart = $iDisk & "||" & $iPartition & "||" & $oPartition.DeviceID & "||" & $oPartition.Type & "||" & $oPartition.PrimaryPartition & "||" & $oPartition.BootPartition & "||" & "" & "||" & "" & "||" & "" & "||" & $oPartition.Size & "||" & "" & "||" & "" & "||" & False
106108
_ArrayAdd($aPartitions, $sNewPart, 0, "||")
107-
109+
108110
; Set DiskInitStyle
109-
if StringRegExp ( $oPartition.Type, "^GPT.*") Then
111+
if StringRegExp($oPartition.Type, "^GPT.*") Then
110112
$aDisks[$iDiskArrayCount][9] = "GPT"
111-
Else
113+
Else
112114
$aDisks[$iDiskArrayCount][9] = "MBR"
113115
EndIf
114-
116+
115117
; Get logical disks
116118
Local $oLogicalDisks = $oWmiInstance.ExecQuery("ASSOCIATORS OF {Win32_DiskPartition.DeviceID='" & $oPartition.DeviceID & "'} WHERE AssocClass = Win32_LogicalDiskToPartition")
117119
For $oLogicalDisk In $oLogicalDisks
@@ -122,27 +124,27 @@ Func _GetDiskInfoFromWmi(ByRef $aDiskList, ByRef $aPartitionList, $bAddTableHead
122124
$aPartitions[$iPartArrayCount][9] = $oLogicalDisk.Size ; Value of LogicalDisk.Size is different to Size of DiskPartition.Size!!
123125
$aPartitions[$iPartArrayCount][10] = ($oLogicalDisk.Size - $oLogicalDisk.FreeSpace)
124126
$aPartitions[$iPartArrayCount][11] = $oLogicalDisk.FreeSpace
125-
126-
; Detect SystemBootDisk
127+
128+
; Detect SystemBootDisk
127129
if $oLogicalDisk.DeviceID = EnvGet("SystemDrive") Then
128130
$aDisks[$iDiskArrayCount][11] = True
129131
$aPartitions[$iPartArrayCount][12] = True
130132
EndIf
131133
Next
132-
134+
133135
; Array counter (Partitions) + 1
134136
$iPartArrayCount += 1
135137
Next
136-
138+
137139
; Array counter (Disks) + 1
138140
$iDiskArrayCount += 1
139141
Next
140142
Else
141143
; If WMI-Error then set @error
142144
SetError(1)
143145
EndIf
144-
146+
145147
; Return Data
146148
$aDiskList = $aDisks
147-
$aPartitionList = $aPartitions
149+
$aPartitionList = $aPartitions
148150
EndFunc ;==>_GetDiskInfoFromWmi

src/GetDiskInfoFromWmi/UsageExample.au3

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
Local $aOutputDisks
77
Local $aOutputPartitions
88
_GetDiskInfoFromWmi($aOutputDisks, $aOutputPartitions, $DiskInfoWmi_TableHeader_Yes, $DiskInfoWmi_DiskType_Fixed)
9-
If @error Then MSGBOX(16, @ScriptName, "Something goes wrong!")
9+
If @error Then MSGBOX(16, @ScriptName, "Something went wrong!")
1010

1111
_ArrayDisplay($aOutputDisks, "Disks")
12-
_ArrayDisplay($aOutputPartitions, "Partitions")
12+
_ArrayDisplay($aOutputPartitions, "Partitions")

0 commit comments

Comments
 (0)