Link to home
Create AccountLog in
Avatar of ReneGe
ReneGeFlag for Canada

asked on

Batch File: Invalid number. Numbers are limited to 32-bits of precison.

Hi there,

I have this script that will not only output the local drives infos, but also convert units to GB.

My problem is when a drive has more than 1TB, I get the following error:
Invalid number. Numbers are limited to 32-bits of precison.

Thanks for your help,
Rene
@ECHO OFF
SETLOCAL ENABLEDELAYEDEXPANSION

IF EXIST %~n0.txt DEL %~n0.txt

FOR /F "tokens=1-7 delims=," %%A IN ('@WMIC LogicalDisk Where DriveType^=^"3^" Get DeviceID^,DriveType^,FileSystem^,FreeSpace^,Size^,VolumeSerialNumber /Format:csv ^| find ^"3^"') DO (
	REM ECHO %%A %%B %%C %%D %%E %%F %%G
	SET DRIVE=%%B
	SET FreeSpace=%%E
	SET TotalSpace=%%F
	SET /A FreeSpace=!FreeSpace:~0,-3!/1024*1000/1024/1024
	SET /A TotalSpace=!TotalSpace:~0,-3!/1024*1000/1024/1024
	ECHO !DRIVE! !TotalSpace!GB !FreeSpace!GB>>%~n0.txt
	)
PAUSE
EXIT

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Psy053
Psy053
Flag of Australia image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
SOLUTION
Avatar of Qlemo
Qlemo
Flag of Germany image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
SOLUTION
Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
Avatar of ReneGe

ASKER

==> bp
According to: https://www.experts-exchange.com/questions/26414453/Batch-File-Convert-bytes-to-either-KB-MB-or-GB-with-2-decimal-points.html
I have the same problem, except that I get the error starting at 100GB insted of 1TB.

https://www.experts-exchange.com/questions/24881845/How-do-i-get-the-Decimal-output-in-the-attached-Batch-Script.html
Provides me with very unaccurate output

==> Qlemo
SET /A FreeSpace=!FreeSpace:~0,-6!/1024*1000/1024
Provides me with very unaccurate output

==> Psy053
The Script does not work.


Thanks guys for helping,
Rene
Avatar of ReneGe

ASKER

Like bp and Psy053 suggested, I think I'll have to go for VBScript.

Since it would be better that I'm in the VB section, I'll split the points here, close this thread and open a new one.

I'll provide you it's link.

Thanks guys,
Rene
Avatar of ReneGe

ASKER

Hi guys,

I thought you may be interested into this one.

https://www.experts-exchange.com/questions/26886544/VBSCRIPT-EXTRACT-EMAIL-ADDRESS-FROM-TEXT-FILE.html

Thanks and cheers,
Rene