@echo off

rem JAM R1.20, EXTEND.BAT -- automatically enlarges a JAM drive. 
rem Sun Jul 10 1994, written by George A. Reznik.
rem Copyright (c) 1992-1994 JAM Software.
rem All Rights Reserved.

echo EXTEND 1.20  Copyright (c) JAM Software, 1992-1994. All rights reserved.
echo:

if "%1" == "" goto usage
if not "%1" == "/?" goto getinfo

:usage
echo Automatically enlages the size of a JAM drive.
echo Use:
echo     EXTEND drive: [size]
echo Where:
echo     drive  JAM drive to extend
echo     size   Specifies amount of physical space (in Kbytes) 
echo            on which JAM drive should be extended.
echo            If not specified the maximum possible value is used.
echo Example:
echo     EXTEND D: -- extend the size of JAM drive D:
echo Note:
echo     Do not run this batch file from the drive you want to extend.
goto end

:getinfo
jmount /q %1 > extend2.bat
if errorlevel 1 goto end
if not exist extend2.bat goto cerror

echo Building secondary command file ...

echo if not "%%4" == "available" goto chkflags	>  jam.bat
echo echo JAM drive %%2 not mounted.		>> jam.bat
echo goto end					>> jam.bat
echo :chkflags					>> jam.bat
echo if not "%%5" == "[Locked]" goto unmount	>> jam.bat
echo echo JAM drive %%2 locked.			>> jam.bat
echo goto end					>> jam.bat
echo :unmount					>> jam.bat
echo echo Deactivating JAM drive %%2 ...	>> jam.bat
echo jmount /q /d %%2				>> jam.bat
echo if errorlevel 1 goto end			>> jam.bat
echo echo Extending the size of %%4 ...		>> jam.bat
echo jsize /q %%4 +%2				>> jam.bat
echo if errorlevel 1 goto end			>> jam.bat
echo echo Remounting JAM drive %%2 ...		>> jam.bat
echo jmount /q /m %%2 %%4			>> jam.bat
echo :end					>> jam.bat
if exist jam.bat goto run

:cerror
echo Cannot create a file on current drive.
goto end

:run
call extend2.bat
del extend2.bat
del jam.bat

:end

