@echo off
cls
echo.
echo.
echo Installing...
echo.
echo.

rem if started from wrong drive
if not exist im_disk1 goto usage3

set ercode=0100
if "%1" == "" goto usage5
goto label2


:label2

set dpath=%1

if exist %dpath%\im_cfg.bak goto startunpak
if not exist %dpath%\imagine.cfg goto startunpak
copy %dpath%\imagine.cfg %dpath%\im_cfg.bak >>%dpath%\install.log


:startunpak

set ercode=0003
if not exist pkunzip.exe goto usage5
set ercode=0004
if not exist im_disk1.zip goto usage5
echo.
echo Please wait...
echo.
set ercode=0000
pkunzip -d -o im_disk1.zip %dpath% >>%dpath%\install.log


:getdisk2

if exist im_disk2 goto cpfile2
echo.
echo.
echo Insert disk 2 of the Imagine 4.0 installation set.
echo.
pause
goto getdisk2


:cpfile2

cls
set ercode=0005
if not exist pkunzip.exe goto usage5
set ercode=0006
if not exist im_disk2.zip goto usage5
set ercode=0000
echo Installing...
echo.
echo Please wait...
echo.
pkunzip -d -o im_disk2.zip %dpath% >>%dpath%\install.log


:getdisk1

if exist im_disk1 goto exit
echo.
echo.
echo Insert disk 1 of the Imagine 4.0 installation set.
echo.
pause
goto getdisk1


:fail

echo.
echo Installation failed
echo.
choice "View installation instructions "
if ERRORLEVEL 2 goto exit
goto usage2


:usage1

echo.
echo Usage:	Install [path]
echo	where [path] is a full MS-DOS path.
echo.
goto exit


:usage2

cls
echo.
echo.
echo IMAGINE 4.0 INSTALLATION INSTRUCTIONS:
echo.
echo On the PC, Insert the first disk of the Imagine 4.0 installation set 
echo into your floppy drive:
echo.
echo Change your current directory to the A: drive by typing:
echo.
echo 	A:\
echo.
echo Then run the installation program by typing:
echo.
echo 	install
echo.
echo (this is assuming your floppy drive is A: - if not, use the drive letter 
echo of your floppy device).  This will install the Imagine software to a 
echo directory on your C: drive named C:\IM40.  
echo.
pause
cls
echo.
echo.
echo To customize the installation so that the software is installed to a 
echo different diectory, append the path you wish to use after the install 
echo command line. For example, type:
echo.
echo 	install D:\IMAGINE
echo.
echo to install the software in drive D: in a directory called \IMAGINE.
goto exit


:usage3

echo.
echo ERROR: Install possibly started from wrong directory.
echo.
pause
goto fail


:usage4

echo.
echo ERROR: unable to copy files to specified directory.
echo.
pause
goto fail

:usage5

echo.
echo ERROR: installation corrupt.  Error code: %ercode%.
echo.
pause
goto fail


:exit
echo.
echo.
