View Single Post
Old 4th July 2019, 06:30   #7
meoit
Member
 
Join Date: Oct 2014
Location: $DESKTOP
Posts: 90
Smile

Thanks Nutzzz.

I edited MyDisks.cmd to count devices as you told.

Quote:
@ECHO OFF
SETLOCAL EnableExtensions EnableDelayedExpansion
SET "InputFile=MyDisks.ini"
IF EXIST "%InputFile%" (DEL /f /q "%InputFile%")
SET /A "Total_Devices=0"
SET /A "Index=0"
@FOR /F "skip=2 tokens=*" %%G IN ('
"WMIC PATH Win32_DiskDrive GET Index /format:csv 2>NUL"
') DO (
SET /A "Total_Devices=Total_Devices+1"
SET /A "Index=Index+1"
>>"%InputFile%" CALL ECHO [Disk%%Index%%]
@FOR /F Tokens^=* %%A IN ('
"WMIC PATH Win32_DiskDrive GET Caption,Size /value 2>NUL"
') DO (
@FOR /F Tokens^=* %%H IN ("%%A") DO (>>"%InputFile%" CALL ECHO %%H)
)
)
>>"%InputFile%" CALL ECHO [Total Devices]
>>"%InputFile%" CALL ECHO Value=%%Total_Devices%%
PAUSE
Then, read MyDisks.ini

Quote:
ReadINIStr $R1 'D:\MyDisks.ini' 'Total Devices' 'Value'
ClearErrors
${For} $R0 0 $R1
ReadINIStr $0 'D:\MyDisks.ini' 'Disk$R0' 'Item'
${IfNot} ${Errors}
${AndIfNot} $0 == ""
MessageBox MB_OK|MB_USERICON '$0'
${EndIf}
${Next}
ClearErrors
But when open MyDisks.ini, I see it double result devices.

Quote:
[Disk1]
Caption=Samsung EVO
Size=232536803840
Caption=Adata USB Device
Size=35718510080
[Disk2]
Caption=Samsung EVO
Size=232536803840
Caption=Adata USB Device
Size=35718510080
[Total Devices]
Value=2
How to fix this?.
meoit is offline   Reply With Quote