@REM **************************************
@REM * 123R4W Software-By-Wire Batch File *
@REM **************************************
@echo off
@if $%echo_flag%$==$$ set echo_flag=OFF
@echo %echo_flag%

set DRIVE=
set DEST=
if $%1$ == $$ goto usage
   set DRIVE=%1
if $DRIVE$ == $$ echo Unable To Set DRIVE Environment Variable.
if $DRIVE$ == $$ goto usage
   shift
if $%1$ == $$ goto usage
   set DEST=%1
if $DEST$ == $$ echo Unable To Set DEST Directory Environment Variable.
if $DEST$ == $$ goto usage
   goto doshift

:chkopt
   if $%1$ == $$ goto chkdir
   if $%1$ == $START$ goto startcp
   goto doshift

:doshift
   shift
   goto chkopt
   goto doshift

:chkdir
if exist %DEST%\*.* goto echohdr
md %DEST%
echo *** Dir Check *** > %DEST%\chk.dir
if not exist %DEST%\chk.dir goto errwdir
if exist %DEST%\chk.dir del %DEST%\chk.dir
goto echohdr

:errwdir
echo Error : Cannot Create Directory %DEST%
goto copyerr

:echohdr
echo ******************************
echo *  123R4W Software-By-Wire   *
echo ******************************

copy crsby.bat %DEST%\.
%DEST%\crsby %DRIVE% %DEST% START

@REM Copy Each Install Disk
:startcp

:disk1
ECHO 
ECHO Insert Disk 1 in DRIVE %DRIVE%
pause
ECHO Copying All Files from Disk 1 to %DEST% . . .
XCOPY %DRIVE%\*.* %DEST%\*.* /s /e /v
if errorlevel 1 echo Error : Copying Disk 1
if errorlevel 1 goto copyerr

:disk2
ECHO 
ECHO Insert Disk 2 in DRIVE %DRIVE%
pause
ECHO Copying All Files from Disk 2 to %DEST% . . .
XCOPY %DRIVE%\*.* %DEST%\*.* /s /e /v
if errorlevel 1 echo Error : Copying Disk 2
if errorlevel 1 goto copyerr

:disk3
ECHO 
ECHO Insert Disk 3 in DRIVE %DRIVE%
pause
ECHO Copying All Files from Disk 3 to %DEST% . . .
XCOPY %DRIVE%\*.* %DEST%\*.* /s /e /v
if errorlevel 1 echo Error : Copying Disk 3
if errorlevel 1 goto copyerr

:disk4
ECHO 
ECHO Insert Disk 4 in DRIVE %DRIVE%
pause
ECHO Copying All Files from Disk 4 to %DEST% . . .
XCOPY %DRIVE%\*.* %DEST%\*.* /s /e /v
if errorlevel 1 echo Error : Copying Disk 4
if errorlevel 1 goto copyerr

:disk5
ECHO 
ECHO Insert Disk 5 in DRIVE %DRIVE%
pause
ECHO Copying All Files from Disk 5 to %DEST% . . .
XCOPY %DRIVE%\*.* %DEST%\*.* /s /e /v
if errorlevel 1 echo Error : Copying Disk 5
if errorlevel 1 goto copyerr

@REM Copy SBY install.ini
:sbyini
if not exist %DEST%\sby.ini echo Error : Missing file %DEST%\sby.ini
if not exist %DEST%\sby.ini goto copyerr
copy %DEST%\sby.ini %DEST%\install.ini

@REM Copy Files to SBY Programs Directory
:progdir
md %DEST%\programs
if not exist %DEST%\readme.txt echo Error : Missing file %DEST%\readme.txt
if not exist %DEST%\readme.txt goto copyerr
copy %DEST%\readme.txt %DEST%\programs\.
if errorlevel 1 goto copyerr
if not exist %DEST%\ivcw.dll echo Error : Missing file %DEST%\ivcw.dll
if not exist %DEST%\ivcw.dll goto copyerr
copy %DEST%\ivcw.dll %DEST%\programs\.
if errorlevel 1 goto copyerr
if not exist %DEST%\123w.ri echo Error : Missing file %DEST%\123w.ri
if not exist %DEST%\123w.ri goto copyerr
copy %DEST%\123w.ri %DEST%\programs\.
if errorlevel 1 goto copyerr

:finished
echo Finished Creating Software-By-Wire Directory.
goto done

:copyerr
echo Unable to Finish Creating Software-By-Wire Directory.
goto done

:usage
echo ÿ
echo 123R4W Software-By-Wire Batch File
echo ÿ
echo Note: If you have not done so already, you must
echo record your Name and Company Name on these
echo disks by running Install before you use CRSBY
echo ÿ
echo USAGE: CRSBY [ SOURCE DRIVE ] [ DESTINATION ] 
echo   eg:   CRSBY a: d:\sby
goto done

:done
echo ÿ
echo Done!
set DRIVE=
set DEST=
