Skip to content

Commit 901a7a5

Browse files
committed
GetDiskInfoFromWmi: Fix typos in script and example. (#21, #22)
1 parent ef0d3f2 commit 901a7a5

2 files changed

Lines changed: 37 additions & 38 deletions

File tree

src/GetDiskInfoFromWmi/GetDiskInfoFromWmi.au3

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

88
#cs
99
===============================================================================================================================
10-
Title ...............: _GetDiskInfoFromWmi (GitHub: - https://github.com/htcfreek/AutoIt-Scripts)
10+
Title ...............: _GetDiskInfoFromWmi (GitHub: https://github.com/htcfreek/AutoIt-Scripts)
1111
Version .............: 1.4
1212
License .............: GNU LGPLv3
1313
AutoIt Version ......: 3.3.14.5+
@@ -21,26 +21,26 @@
2121
2222
CHANGELOG:
2323
2021-07-05 (v1.4)
24-
Fixed: Typos in script and example.
24+
Fix: Typos in script and example.
2525
2626
2021-07-04 (v1.3)
27-
Fixed: Typos
28-
Changed: Improved comments
29-
Changed: Disk property header renamed: WindowsRunningOnDisk (SystemRoot) -> WindowsRunningOnDisk (SystemDisk)
30-
Changed: Partition property header renamed: PartitionIsSystemRoot -> PartitionIsSystemDisk
31-
Add: DiskType filter
32-
Add: Constants
33-
Add: Required includes
34-
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
3535
3636
2021-07-02 (v1.2)
37-
Added: Disk properties Manufacturer, Interfacetype, Mediatype, Serialnumber, Status
38-
Added: Partition property: Filesystem
39-
Changed: Disk property header renamed: SystemIsBootedFromDisk -> WindowsRunningOnDisk (SystemRoot)
40-
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
4141
4242
2021-07-02 (v1.0)
43-
Initial release
43+
New: Initial release
4444
4545
#ce
4646

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

6161
; Function
6262
; ---------
63-
6463
Func _GetDiskInfoFromWmi(ByRef $aDiskList, ByRef $aPartitionList, $bAddTableHeader = $DiskInfoWmi_TableHeader_Yes, $sFilterDiskType = $DiskInfoWmi_DiskType_All)
65-
; Name ...............: _GetDiskInfoFromWmi
64+
; Name ...............: _GetDiskInfoFromWmi
6665
; Author .............: htcfreek (Heiko) - https://github.com/htcfreek
67-
; Input parameter ....: ByRef $aDiskList = Array var for list of disks.
66+
; Input parameter ....: ByRef $aDiskList = Array var for list of disks.
6867
; ByRef $aPartitionList = Array var for list of partitions.
6968
; [$bAddTableHeader = $DiskInfoWmi_TableHeader_Yes] = Should array tables have a header row. (Values: 0|1 or $DiskInfoWmi_TableHeader_Yes|$DiskInfoWmi_TableHeader_No)
7069
; [$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)
71-
; Output parameter ...: none
70+
; Output parameter ...: none
7271
; On WMI-Error .......: @error = 1
73-
74-
72+
73+
7574
; Initialize function wide vars
7675
Local $aDisks[0][12]
7776
Local $aPartitions[0][13]
78-
Local $iDiskArrayCount = 0 ; Initialize counter to write some disk data later in correct array row.
79-
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+
8080

81-
8281
; Add Array header
83-
if ($bAddTableHeader = 1) Then
82+
if ($bAddTableHeader = 1) Then
8483
$sDiskHeader = "DiskNum" & "||" & "DiskDeviceID" & "||" & "DiskManufacturer" & "||" & "DiskModel" & "||" & "DiskInterfaceType" & "||" & "DiskMediaType" & "||" & "DiskSerialNumber" & "||" & "DiskState" & "||" & "DiskSize" & "||" & "DiskInitType" & "||" & "DiskPartitionCount" & "||" & "WindowsRunningOnDisk (SystemDrive)"
8584
_ArrayAdd($aDisks, $sDiskHeader, 0, "||")
8685
$sPartitionHeader = "DiskNum" & "||" & "PartitionNum" & "||" & "PartitionID" & "||" & "PartitionType" & "||" & "PartitionIsPrimary" & "||" & "PartitionIsBootPartition" & "||" & "PartitionLetter" & "||" & "PartitionLabel" & "||" & "PartitionFileSystem" & "||" & "PartitionSizeTotal" & "||" & "PartitionSizeUsed" & "||" & "PartitionSizeFree" & "||" & "PartitionIsSystemDrive"
@@ -99,22 +98,22 @@ Func _GetDiskInfoFromWmi(ByRef $aDiskList, ByRef $aPartitionList, $bAddTableHead
9998
Local $iDisk = $oDisk.Index
10099
Local $sNewDisk = $iDisk & "||" & $oDisk.DeviceID & "||" & $oDisk.Manufacturer & "||" & $oDisk.Model & "||" & $oDisk.InterfaceType & "||" & $oDisk.MediaType & "||" & $oDisk.SerialNumber & "||" & $oDisk.Status & "||" & $oDisk.Size & "||" & "<DiskInitStyle>" & "||" & $oDisk.Partitions & "||" & False
101100
_ArrayAdd($aDisks, $sNewDisk, 0, "||")
102-
101+
103102
; Get Partitions
104103
Local $oPartitions = $oWmiInstance.ExecQuery("ASSOCIATORS OF {Win32_DiskDrive.DeviceID='" & $oDisk.DeviceID & "'} WHERE AssocClass = Win32_DiskDriveToDiskPartition")
105104
For $oPartition In $oPartitions
106105
; Add Partition data to Array
107106
Local $iPartition = $oPartition.Index
108107
Local $sNewPart = $iDisk & "||" & $iPartition & "||" & $oPartition.DeviceID & "||" & $oPartition.Type & "||" & $oPartition.PrimaryPartition & "||" & $oPartition.BootPartition & "||" & "" & "||" & "" & "||" & "" & "||" & $oPartition.Size & "||" & "" & "||" & "" & "||" & False
109108
_ArrayAdd($aPartitions, $sNewPart, 0, "||")
110-
109+
111110
; Set DiskInitStyle
112-
if StringRegExp ( $oPartition.Type, "^GPT.*") Then
111+
if StringRegExp($oPartition.Type, "^GPT.*") Then
113112
$aDisks[$iDiskArrayCount][9] = "GPT"
114-
Else
113+
Else
115114
$aDisks[$iDiskArrayCount][9] = "MBR"
116115
EndIf
117-
116+
118117
; Get logical disks
119118
Local $oLogicalDisks = $oWmiInstance.ExecQuery("ASSOCIATORS OF {Win32_DiskPartition.DeviceID='" & $oPartition.DeviceID & "'} WHERE AssocClass = Win32_LogicalDiskToPartition")
120119
For $oLogicalDisk In $oLogicalDisks
@@ -125,27 +124,27 @@ Func _GetDiskInfoFromWmi(ByRef $aDiskList, ByRef $aPartitionList, $bAddTableHead
125124
$aPartitions[$iPartArrayCount][9] = $oLogicalDisk.Size ; Value of LogicalDisk.Size is different to Size of DiskPartition.Size!!
126125
$aPartitions[$iPartArrayCount][10] = ($oLogicalDisk.Size - $oLogicalDisk.FreeSpace)
127126
$aPartitions[$iPartArrayCount][11] = $oLogicalDisk.FreeSpace
128-
129-
; Detect SystemBootDisk
127+
128+
; Detect SystemBootDisk
130129
if $oLogicalDisk.DeviceID = EnvGet("SystemDrive") Then
131130
$aDisks[$iDiskArrayCount][11] = True
132131
$aPartitions[$iPartArrayCount][12] = True
133132
EndIf
134133
Next
135-
134+
136135
; Array counter (Partitions) + 1
137136
$iPartArrayCount += 1
138137
Next
139-
138+
140139
; Array counter (Disks) + 1
141140
$iDiskArrayCount += 1
142141
Next
143142
Else
144143
; If WMI-Error then set @error
145144
SetError(1)
146145
EndIf
147-
146+
148147
; Return Data
149148
$aDiskList = $aDisks
150-
$aPartitionList = $aPartitions
149+
$aPartitionList = $aPartitions
151150
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)