Skip to content

Commit

Permalink
Merge v1.3.2 into main
Browse files Browse the repository at this point in the history
  • Loading branch information
htcfreek authored Aug 28, 2022
2 parents 2d2c63d + ab2d95b commit bf01e99
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/GetDiskInfoFromWmi/GetDiskInfoFromWmi.au3
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#cs
===============================================================================================================================
Title ...............: _GetDiskInfoFromWmi (GitHub: https://github.com/htcfreek/AutoIt-Scripts)
Version .............: 1.4.1
Version .............: 1.4.2
License .............: GNU LGPLv3
AutoIt Version ......: 3.3.14.5+
Language ............: English
Expand All @@ -20,6 +20,10 @@
===============================================================================================================================
CHANGELOG:
2022-08-28 (v1.4.2)
Fixed: Build warnings for non declared variables $sDiskHeader and $sPartitionHeader. (Github#28)
Added: New Readme.txt for this script. (Github#29)
2021-07-06 (v1.4.1)
Fixed: Code styling
Expand Down Expand Up @@ -66,26 +70,27 @@ Global Const $DiskInfoWmi_DiskType_Unknown = "Unknown%"
Func _GetDiskInfoFromWmi(ByRef $aDiskList, ByRef $aPartitionList, $bAddTableHeader = $DiskInfoWmi_TableHeader_Yes, $sFilterDiskType = $DiskInfoWmi_DiskType_All)
; Name ...............: _GetDiskInfoFromWmi
; Author .............: htcfreek (Heiko) - https://github.com/htcfreek
; Input parameter ....: ByRef $aDiskList = Array var for list of disks.
; ByRef $aPartitionList = Array var for list of partitions.
; Input parameter ....: ByRef $aDiskList = Array variable for list of disks returned.
; ByRef $aPartitionList = Array variable for list of partitions returned.
; [$bAddTableHeader = $DiskInfoWmi_TableHeader_Yes] = Should array tables have a header row. (Values: 0|1 or $DiskInfoWmi_TableHeader_Yes|$DiskInfoWmi_TableHeader_No)
; [$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)
; [$sFilterDiskType = $DiskInfoWmi_DiskType_All] = Which type of disk should be included in the result. (Values: $DiskInfoWmi_DiskType_All|$DiskInfoWmi_DiskType_External|$DiskInfoWmi_DiskType_Removable|$DiskInfoWmi_DiskType_Fixed|$DiskInfoWmi_DiskType_Unknown)
; Output parameter ...: none
; On WMI-Error .......: @error = 1


; Initialize function wide vars
Local $aDisks[0][12]
Local $aPartitions[0][13]

Local $iDiskArrayCount = 0 ; Initialize counter to write some disk data later in correct array row.
Local $iPartArrayCount = 0 ; Initialize counter to write partition data later in correct array row.


; Add Array header
If ($bAddTableHeader = 1) Then
$sDiskHeader = "DiskNum" & "||" & "DiskDeviceID" & "||" & "DiskManufacturer" & "||" & "DiskModel" & "||" & "DiskInterfaceType" & "||" & "DiskMediaType" & "||" & "DiskSerialNumber" & "||" & "DiskState" & "||" & "DiskSize" & "||" & "DiskInitType" & "||" & "DiskPartitionCount" & "||" & "WindowsRunningOnDisk (SystemDrive)"
Local $sDiskHeader = "DiskNum" & "||" & "DiskDeviceID" & "||" & "DiskManufacturer" & "||" & "DiskModel" & "||" & "DiskInterfaceType" & "||" & "DiskMediaType" & "||" & "DiskSerialNumber" & "||" & "DiskState" & "||" & "DiskSize" & "||" & "DiskInitType" & "||" & "DiskPartitionCount" & "||" & "WindowsRunningOnDisk (SystemDrive)"
_ArrayAdd($aDisks, $sDiskHeader, 0, "||")
$sPartitionHeader = "DiskNum" & "||" & "PartitionNum" & "||" & "PartitionID" & "||" & "PartitionType" & "||" & "PartitionIsPrimary" & "||" & "PartitionIsBootPartition" & "||" & "PartitionLetter" & "||" & "PartitionLabel" & "||" & "PartitionFileSystem" & "||" & "PartitionSizeTotal" & "||" & "PartitionSizeUsed" & "||" & "PartitionSizeFree" & "||" & "PartitionIsSystemDrive"
Local $sPartitionHeader = "DiskNum" & "||" & "PartitionNum" & "||" & "PartitionID" & "||" & "PartitionType" & "||" & "PartitionIsPrimary" & "||" & "PartitionIsBootPartition" & "||" & "PartitionLetter" & "||" & "PartitionLabel" & "||" & "PartitionFileSystem" & "||" & "PartitionSizeTotal" & "||" & "PartitionSizeUsed" & "||" & "PartitionSizeFree" & "||" & "PartitionIsSystemDrive"
_ArrayAdd($aPartitions, $sPartitionHeader, 0, "||")
$iDiskArrayCount += 1
$iPartArrayCount += 1
Expand Down
25 changes: 25 additions & 0 deletions src/GetDiskInfoFromWmi/Readme.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
**********************************************************************
* Name: _GetDiskInfoFromWmi *
* Description: Returns disk and partition information from WMI. *
* Author: htcfreek (Heiko) - https://github.com/htcfreek [original] *
**********************************************************************

Detailed description:
---------------------
This function generates two arrays conatining the list of all disks on this computer and all partitions on this computer. The arrays are returned using the output parameters of the function.
There are two more fucntion parameters you can use to control the output: One to decide if the array tables should have a header line and one to control which types of disks are returned.

Parameters:
-----------
1. ByRef $aDiskList : Array variable for list of disks returned.
2. ByRef $aPartitionList : Array variable for list of partitions returned.
3. $bAddTableHeader (Optional, Default value = $DiskInfoWmi_TableHeader_Yes) : Should array tables have a header row. (Values: 0|1 or $DiskInfoWmi_TableHeader_Yes|$DiskInfoWmi_TableHeader_No)
4. $sFilterDiskType (Optional, Default value = $DiskInfoWmi_DiskType_All) : Which type of disk should be included in the result. (Values: $DiskInfoWmi_DiskType_All|$DiskInfoWmi_DiskType_External|$DiskInfoWmi_DiskType_Removable|$DiskInfoWmi_DiskType_Fixed|$DiskInfoWmi_DiskType_Unknown)

Output:
-------
Two array lists. One contains the disk information and one contains the partition information.

Usage example:
--------------
See the file 'UsageExample.au3' in this directory.

0 comments on commit bf01e99

Please sign in to comment.