@echo off
cls

echo .------------------------------------------------------------------
echo .                           mkbootrmd.bat                             
echo .------------------------------------------------------------------
echo . 				
echo . ****************************************************************
echo .  		             WARNING:
echo .  		            ----------
echo . 
echo . * ----------------------------------------
echo . * THIS UTILTIY FORMATS THE RMD
echo . * THE DATA ON THE CARD WILL BE ERASED....! 
echo . * ----------------------------------------
echo .
echo . * This utility creates Bootable RMD for CS 1000M and CS 1000E,
echo .   which can be used to boot a system with CP PIV processors.
echo . 
echo . * This utility assumes that the drive entered is correct.
echo .   So, please enter the correct RMD drive.
echo .
echo . 
echo . ****************************************************************** 
echo .
echo . Please insert a RMD (Compact Flash) in drive now.
echo .
pause
if Windows_NT == %OS% goto winnt
echo .
SET drv = 
choice /n /C:ABCDEFGHIJKLMNOPQRSTUVWXYZ Please enter the Drive letter of your RMD:

if ERRORLEVEL == 1  SET drv=A
if ERRORLEVEL == 2  SET drv=B
if ERRORLEVEL == 3  SET drv=C
if ERRORLEVEL == 4  SET drv=D
if ERRORLEVEL == 5  SET drv=E
if ERRORLEVEL == 6  SET drv=F
if ERRORLEVEL == 7  SET drv=G
if ERRORLEVEL == 8  SET drv=H
if ERRORLEVEL == 9  SET drv=I
if ERRORLEVEL == 10 SET drv=J
if ERRORLEVEL == 11 SET drv=K
if ERRORLEVEL == 12 SET drv=L
if ERRORLEVEL == 13 SET drv=M
if ERRORLEVEL == 14 SET drv=N
if ERRORLEVEL == 15 SET drv=O
if ERRORLEVEL == 16 SET drv=P
if ERRORLEVEL == 17 SET drv=Q
if ERRORLEVEL == 18 SET drv=R
if ERRORLEVEL == 19 SET drv=S
if ERRORLEVEL == 20 SET drv=T
if ERRORLEVEL == 21 SET drv=U
if ERRORLEVEL == 22 SET drv=V
if ERRORLEVEL == 23 SET drv=W
if ERRORLEVEL == 24 SET drv=X
if ERRORLEVEL == 25 SET drv=Y
if ERRORLEVEL == 26 SET drv=Z

format %drv%: /V:CS1000BOOT
if errorlevel 1 goto formatfail
echo .
echo . RMD format Successful ...
echo .
echo . Installing Boot sector ...
echo .
lock %drv%:
vxsys %drv%:
unlock %drv%:
if errorlevel 1 goto sysfail
goto win

:winnt
SET /P drv=Please enter the Drive letter of your RMD:

echo .

format %drv%: /V:CS1000BOOT
if errorlevel 1 goto formatfail

echo .
echo . RMD format Successful ...
echo .
echo . Installing Boot sector ...
echo .
vxboot %drv%:
if errorlevel 1 goto sysfail

:win
echo .
echo . Copying files . . .
echo .

copy fdrom.bin %drv%:\bootrom.sys > nul
if errorlevel 1 goto cpfailbt

echo . bootrom.sys copied OK.
echo .
echo . Check whether the follwoing output shows 
echo . "All the specified file(s) are contiguous"
echo .
pause
chkdsk %drv%:\bootrom.sys
echo .
pause
echo .

copy nvram.sys %drv%:\nvram.sys > nul
if errorlevel 1 goto cpfailnv
echo . nvram.sys copied OK.

:complete
echo .
echo . The Bootable RMD is SUCCESSFULLY created.
echo . You may close this window now.
echo .
goto end

:formatfail
echo .
echo . Failed to format RMD...!
echo . FIX THE PROBLEMS AND TRY AGAIN...!
echo .
pause
goto end

:sysfail
echo .
echo . Failed to install boot sector on to RMD...!
echo . vxboot.exe may not be present...!
echo . FIX THE PROBLEMS AND TRY AGAIN...!
echo .
pause
goto end

:cpfailbt
echo .
echo . Failed to copy BOOTROM.SYS!
echo . Check whether you have fdrom.bin file.
echo . FIX THE PROBLEMS AND TRY AGAIN...!
echo .
pause
goto end

:cpfailnv
echo .
echo . Failed to copy NVRAM.SYS!
echo . FIX THE PROBLEMS AND TRY AGAIN...!
echo .
pause

echo .
goto end

:end

