rem check if user pressed key to request re-initialization
rem this is only relevant if enabled by the PxDiS option!
if not _#@T254*##### == _PxKeY goto PHASE
cls
echo User requested reinstallation at boot time
goto REINSTALL

rem determine installation phase
:PHASE
pxfdisk -c 80 0 00
if ERRORLEVEL 1 goto PHASE0

pxfdisk -c 80 0 a1
if ERRORLEVEL 1 goto PHASE1
pxfdisk -c 80 0 61
if ERRORLEVEL 1 goto PHASE1

pxfdisk -c 80 0 a2
if ERRORLEVEL 1 goto PHASE2
pxfdisk -c 80 0 62
if ERRORLEVEL 1 goto PHASE2

pxfdisk -c 80 0 a3
if ERRORLEVEL 1 goto REINSTALL
pxfdisk -c 80 0 63
if ERRORLEVEL 1 goto REINSTALL

rem unknown phase - perform reinstallation
cls
echo Unknown Phase !

:REINSTALL
echo.
echo Press a key to clean the hard disk and restart installation.
pause

pxfdisk -m 80 0 N 00 0 0 0 0 0 0 0 0 -f
pxfdisk -m 80 1 N 00 0 0 0 0 0 0 0 0 -f
pxfdisk -m 80 2 N 00 0 0 0 0 0 0 0 0 -f
pxfdisk -m 80 3 N 00 0 0 0 0 0 0 0 0 -f
goto PHASE


rem Phase 0: Partition the hard disk
:PHASE0
cls
echo PHASE0: Create a DOS partition on the hard disk
echo.

rem create flag partition 0
pxfdisk -m 80 0 N 00 10m -f

rem create an active DOS partition 1
pxfdisk -m 80 1 y 06 #@T200*##m -f

rem clear partition 2 and 3
pxfdisk -m 80 2 N 00 0 0 0 0 0 0 0 0 -f
pxfdisk -m 80 3 N 00 0 0 0 0 0 0 0 0 -f

rem write master boot record
pxfdisk -b 80

rem check installation line
if _#@T253*##### == _PxInS1 goto PHASE0_2

rem set flag partition 0 to the value 61
pxfdisk -o 80 0 61
reboot

:PHASE0_2
rem set flag partition 0 to the value A1
pxfdisk -o 80 0 a1
reboot


:PHASE1
cls
echo PHASE1: Format DOS partition
echo.

rem PXFDISK quick format
pxfdisk -q 80 -f

rem flag that we are done with phase1
pxfdisk -a 80 0 1
goto PHASE


:PHASE2
cls
echo PHASE2: Connect to server and run NT installation
echo.

cd \net
rem initialize TCP/IP stack
pxutil -p a:\net\protocol.ini
pxutil -a a:\net\system.ini
pxutil -a a:\net\lmhosts
net initialize
netbind
umb
tcptsr
tinyrfc
nmtsr
emsbfr

rem logon to installation server
net logon #@T162*########################################### /savepw:no /y
rem connect w: to general installation share
net use w: \\#@T160*#########\CLIENTS

rem copy unattend.txt file for our configuration
copy w:\winnt\config\#@T161*#########\unattend.txt a:\

rem patch unattend.txt file with DHCP/BOOTP information
pxutil -a a:\unattend.txt
mkdir c:\temp
copy a:\unattend.txt c:\temp\unattend.txt

rem load SmartDrive to speed things up
lh smartdrv 32768 > NUL:
lh smartdrv 16384 > NUL:
lh smartdrv  8192 > NUL:

rem cd to installation directory
w:
cd \winnt\netsetup

rem flag that we are done with PHASE2
pxfdisk -a 80 0 1

rem run Windows NT installation
winnt /b /s:w:\winnt\netsetup /u:c:\temp\unattend.txt

rem !UNREACHED! as WINNT will reboot after install
reboot


:end