Whats get wrong in this script?
The script need to check for 20 GB on c and if there is continue with it's process..
please advice...
SETLOCAL ENABLEEXTENSIONS
setlocal ENABLEDELAYEDEXPANSION
FOR /F "tokens=1-3" %%n IN ('"WMIC LOGICALDISK GET Name,Size,FreeSpace | find /i "C""') DO SET FreeBytes=%%n
SET /A FreeSpace=!FreeBytes:~0,-10!
ECHO %FreeSpace%
IF %FreeSpace% LSS 20 (
"%~d0\MessageBox.vbs" "You need at least 20 Gb on c to preform the installation."
EXIT 1
) ELSE (
call "%~d0\Commands.bat"
call "%~dp0\setup.exe"
Script .. what the problem..
Moderator: DosItHelp
Re: Script .. what the problem..
Remove the /A as it is not a mathematical command.
SET /A FreeSpace=!FreeBytes:~0,-10!
and the trailing ) is missing.
SET /A FreeSpace=!FreeBytes:~0,-10!
and the trailing ) is missing.
Re: Script .. what the problem..
I would also check for megabytes in the case that a drive is very full
Code: Select all
@echo off
SETLOCAL ENABLEEXTENSIONS
setlocal ENABLEDELAYEDEXPANSION
FOR /F %%n IN ('"WMIC LOGICALDISK GET Name,Size,FreeSpace | find /i "C:""') DO SET FreeBytes=%%n
SET FreeSpace=!FreeBytes:~0,-6!
if not defined freespace set freespace=0
ECHO %FreeSpace%
IF %FreeSpace% LSS 20000 (
"%~d0\MessageBox.vbs" "You need at least 20 Gb on c to perform the installation."
EXIT /b 1
) ELSE (
call "%~d0\Commands.bat"
call "%~dp0\setup.exe"
)
pause
Re: Script .. what the problem..
Thanks
If you check that is lss then 20 gb it's not including there is no space at all?
If you check that is lss then 20 gb it's not including there is no space at all?
Re: Script .. what the problem..
The line that checks if the freespace variable is defined will handle situations when the drive is completely full.
I changed the way that works in the code I posted in the previous message. See above.
I changed the way that works in the code I posted in the previous message. See above.