Boot Batchnotes

Main.SideBar

FreeDOS Sections (components)

PmWiki

Boot Batchnotes

FDAUTO.BAT, the FreeDOS bootup automation file!!!

Your harddisk will need to be prepared to contain FreeDOS. This means files can only be stored on filesystems that this operating system supports, which means you have the choice of FAT12, FAT16 and FAT32.

The FDAUTO.BAT script can take care of many of the required needs. Classic partitioning is supported, as well as disk formatting and gaining access to cdrom by loading required drivers for it.

In fact this file will run most of the time if you're running it from a physical diskette. After all, executing bootsectors, the kernel, config.sys and the command interpreter only take a few seconds in total.

This bootdisk will not do fine if you need to resize any partitions. Use external programs for that (untested except Partition Magic). This bootdisk will do fine however in the following cases:
* Already FAT partition present

  • Still empty unpartitioned space to create a FAT partition
  • You are willing to delete a partition in order to create a FAT partition.

If you're creating a FAT partition, please make it a primary partition, and set it active.

The batchfile (or batchscript, a set of DOS commands understood by the command interpreter) below is responsible for:

  • Set up environment variables
  • Ensure we're running the correct command interpreter
  • Find required files
  • Start caching setup files to accelerate execution of batchfile and programs
  • Check if a drive C: exists. Normally this is first active primary partition of the first harddisk
  • Check if C: really is on harddisk. Sometimes cdrom and ramdisk are able to get drive C: assigned..
  • Check if C: is actually formatted (writable, has enough free diskspace, fat12/16 or 32)
  • Check if C: already contains another operating system by checking bootsector and kernelfiles. If already present, we need to setup dualboot ourselves, or add FreeDOS to dualboot manager, or overwrite the other operating system if allowed

Once this is done, we can start accessing source medium. Preferably this is a cdrom, but diskette installation should still also be possible. Additional installation sources are: * mounting an ISO file on either cdrom or harddisk

  • installation from a directory on harddisk
  • installation from the internet, by downloading the ISO file and then mounting it.

Depending if you do a cdrom-like installation or a diskette-like installation, either the cdrom batchfile (autorun.bat) takes over, or the FreeDOS textmode installer. After installation of FreeDOS packages, a configuration will be set up (installation disk 1, package samcfg.zip, file postinst.bat) to make the best use of your DOS system.

After installation, you should be able to reboot.


@echo off
for %%x in ( %0 %0.bat ) do if exist %%x CDD %%x
CD \
for %%x in ( "%errorlevel%" "%_CWD%" ) do if "%%x"==""""goto end
for %%x in ( %OS% %CD% ) do if not "%%x"=="" goto end
if not "%_CWD%"=="A:\" goto init
for %%x in ( A:\ B:\ ) do if "%_CWD%"=="%%x%" set path=%%x
if exist %_CWD%\NUL SET PATH=%_CWD%
for %%x in ( A:\FREEDOS A:\DRIVER A:\SPECIAL ) do if exist %%x\NUL SET PATH=%path%;%%x
set dircmd=/ogn /4
set errlabel=FindIMG
pushd A:\
goto ChkProg1

rem Kernel hates us: SHELLHIGH broken, FNODE stuff with SHFDRV, DOS=HIGH + MS HIMEM (WIN98)
rem All executables in path, all other files need their location to be detected


:ChkProg1
for %%x in ( %path% ) do if exist %%x\localize.com goto ChkProg2
if "%errlabel%"=="" set errlabel=ErrProg
goto %errlabel%

:ChkProg2
for %%x in ( %path% ) do if exist %%x\oscheck.com goto ChkProg3
goto %errlabel%

:ChkProg3
for %%x in ( %path% ) do if exist %%x\fdisk.exe goto ChkProg4
goto %errlabel%

:ChkProg4
for %%x in ( %path% ) do if exist %%x\choice.exe goto GoodFile
goto %errlabel%

:FindIMG
set errlabel=
if not exist a:\fdboot.img goto postfdsk
for %%x in ( %path% ) do if exist %%x\shrdrv86.exe goto img2ram
goto ChkProg5

:img2ram
shrdrv86.exe /F:a:\fdboot.img,D
if "%errorlevel%"=="255" goto ChkProg5
for %%x in ( A B C D E F G H I J K L M N O P Q R S T U V W X Y Z ) do if errorlevel H%%x set fileroot=%%x:
CDD %fileroot%\
if exist %fileroot%\command.com set comspec=%fileroot%\command.com
set path=%fileroot%\FREEDOS;%fileroot%\DRIVER;%path%
goto ChkProg1

:ChkProg5
for %%x in ( %path% ) do if exist %%x\shfdrv86.exe goto img2disk
goto postfdsk

:img2disk
shfdrv86.exe /F:a:\fdboot.img,D
if "%errorlevel%"=="255" goto postfdsk
for %%x in ( A B C D E F G H I J K L M N O P Q R S T U V W X Y Z ) do if errorlevel H%%x set fileroot=%%x:
set path=%path%;%fileroot%\FREEDOS;%fileroot%\DRIVER
goto ChkProg1

:ErrProg
echo Fatal error: missing program!
goto end


:GoodFile
pushd A:\
pushd C:\
if not "%_CWD%"=="C:\" goto findHDD
CDD %filedrv%
OScheck C:
if "%errorlevel%"=="130" goto findHDD
goto postfdsk

:findHDD
fdisk /status
cls
if "%errorlevel%"=="6" goto postfdsk
echo 1) Run FDISK to create at least 1 active primary partition ("drive C:")
echo that uses the FAT(12/16/32) filesystem to store programs and data
echo 2) Skip running Fdisk and continue SETUP
echo 3) Reboot system
choice /N /C:123 Make your choice:
if "%errorlevel%"=="3" Fdisk /REBOOT
if "%errorlevel%"=="2" goto postfdsk
Fdisk /MONO
goto findHDD


:postfdsk
POPD
POPD *
if exist XMSXXXX0 goto init
for %%x in ( %path% A:\SPECIAL ) do if exist %%x\fdxms286.sys set XMSFILE=%%x\fdxms286.sys
goto premenu

:premenu
cls
if not "%XMSFILE%"=="" echo L - Load XMS driver
echo C - Continue FreeDOS SETUP
echo R - Run program(s) from commandline
if not "%XMSFILE%"=="" choice /N /C:CLR /T:L,5 Make your choice:
if "%XMSFILE%"=="" choice /N /C:CLR /T:C,5 Make your choice:
if "%errorlevel%"=="3" goto userprog
if "%errorlevel%"=="2" goto findXMS
if "%errorlevel%"=="1" goto init
cls
goto premenu

:findXMS
if exist XMSXXXX0 goto premenu
for %%x in ( %path% ) do if exist %%x\devload.com goto loadXMS
goto premenu

:loadXMS
devload %XMSFILE%
REM %comspec% %comspec% /checkXMS
set XMSFILE=
cls
goto premenu

:userprog
if exist XMSXXXX0 echo type EXIT to return to menu
if exist XMSXXXX0 %comspec% /K %myprog% %options%
if not exist XMSXXXX0 echo type FDAUTO to return to menu
if not exist XMSXXXX0 goto end
set prompt=$P$G
goto premenu


:init
if "%filedrv%"=="" set filedrv=A:
if "%bootdrv%"=="" set bootdrv=A:
if not "%label%"=="" goto %label%
pushd
for %%x in ( %path% ) do if exist %%x\NLSSETUP.ZIP CDD %%x
tunz -o NLSsetup.zip %bootdrv%\freedos\
if exist %bootdrv%\freedos\NLSsetup.bat call %bootdrv%\freedos\NLSsetup.bat
for %%x in ( %path% ) do if exist %%x\NLSsetup.zip del %bootdrv%\freedos\NLSsetup.bat
popd
if not "%nlspath%"=="" goto loadxdma
echo.
echo Error: Could not start necessary file '%bootdrv%\freedos\NLSsetup.bat'
goto end


:loadxdma
if not "%CPUTYPE%"=="80386" goto loopchk
if not exist XMSXXXX0 goto loopchk
for %%x in ( %path% ) do if exist %%x\xdma.sys set XDMAFILE=%%x\xdma.sys
if not "%XDMAfile%"=="" devload /Q /H %XDMAfile%
set XDMAfile=
goto loopchk

:loopchk
set chklabel=loopchk
OScheck C:
set checklvl=%errorlevel%
cls
if "%checklvl%"=="130" goto begin
cls
if errorlevel 41 goto toohigh
if errorlevel 4 set safeC=true
if errorlevel 4 goto begin
if "%checklvl%"== "1" goto format_c
if "%checklvl%"== "3" localize 1.3
if "%checklvl%"== "2" localize 1.4
if "%checklvl%"== "0" localize 1.2
set chklabel=begin
goto pausenow

:pausenow
localize 1.0 %checklvl% )
pause
goto %chklabel%

:toohigh
localize 1.1
set chklabel=begin
goto pausenow

:format_c
cls
for %%x in ( 0 1 ) do localize 2.%%x
localize 2.2 %checklvl%]
format C: /V:C_FREEDOS9
oscheck C:
if "%errorlevel%"=="3" SYS C: C: /BOOTONLY /OEM:FD
pause
goto loopchk


:begin
rem "SafeC"=="true" means we can store crap on harddisk
for %%x in ( corename chklabel label chklabel checklvl ) do SET %%x=
goto loadISO

:loadISO
rem Consider the ODIN LOADCD.BAT file
if "%virtualcd%"=="" set virtualcd=C:\FDBOOTCD.ISO
if exist %virtualcd% LH SHSUCDHD /F:%virtualcd%,D
goto initcdex

:initcdex
set number=1 2 3 4 5 6
set cdname0=SHSU-CDH
for %%x in ( %number% ) do if "%cdname%%x%"=="" set cdname%%x=FDCD000%%x
rem this is a new check, check for correctness [BBL 2005-08-07]
for %%x in ( 0 %number% ) do if exist %cdname%%x% goto usermenu
goto load_elt

:load_elt
if exist %cdname0% goto usermenu
if not "%WHO%"=="3" goto load_IDE
call cddriver.bat FDAUTO eltorito.sys /D:%cdname1%
if not exist %cdname1% set delay=12
goto load_ide

rem call %filedrv%\driver\cddriver.bat FDAUTO load_ATA eltorito.sys /D:%cdname1%

:load_ide
if "%WHO%"=="1" set extfiles=B:\DRIVER %extfiles%
if exist %cdname1% goto load_ATA
if not "%cputype%"=="80386" goto load_ATA
call cddriver.bat FDAUTO vide-cdd.sys /D:%cdname1%
goto load_ATA

:load_ATA
if "%WHO%"=="" goto loadSCSI
goto loadSCSI
goto nocdrom1

:nocdrom1
if exist %cdname1% goto loadSCSI
call cddriver.bat FDAUTO atapicdd.sys /D:%cdname1%
goto loadSCSI

:loadSCSI
set diskdrv=
if exist %cdname1% goto usermenu
call cddriver.bat FDAUTO ASPICDRW.SYS
call cddriver.bat FDAUTO ASPICDRW.SYS /D:%cdname1%
goto usermenu

:usermenu
if exist SHSU-CDH set cdname1=SHSU-CDH
for %%x in ( %number% ) do if exist %cdname%%x% set drivesrc=true
if "%drivesrc%"=="" GOTO nocdrom
rem goto usrdelay
goto medium5


:nocdrom3
:usrdelay
if "%delay%"=="" set delay=5
set timeout=
if not "%drivesrc%"=="" set timeout=/t:0,%delay%
cls
for %%x in ( 1 0 2 ) do localize 5.%%x
if not "%drivesrc%"=="" localize 5.3 %delay%s)
for %%x in ( 0 4 5 6 ) do localize 5.%%x
if not "%drivesrc%"=="" localize 5.7
choice /N /C:12340 %timeout% Make your choice:
goto medium%errorlevel%

:nocdrom0
:nomedium
:medium4
:nocdrom
cls
for %%x in ( 1 ) do if "%drivesrc%"=="" localize 4.%%x
for %%x in ( 0 2 0 3 4 ) do localize 4.%%x
for %%x in ( 5 6 ) do if "%drivesrc%"=="" localize 4.%%x
if exist \special\wget.exe localize 4.7
if "%who%"=="1" localize 4.7
choice /N /C:12345 Make your choice:
goto nocdrom%errorlevel%

:medium6
:nocdrom5
For %%x in ( %path% ) do if exist %%x\wwwsetup.bat set wwwbatch=%%x\wwwsetup.bat
if "%wwwbatch%"=="" goto nocdrom
call %wwwbatch% %packet%
if not "%usrinput%"=="" goto testfile
REM for %%x in ( 1 2 3 4 5 6 ) do if exist FDCD000%%x goto medium5
if not "%virtualcd%"=="" goto mountiso
echo SETUP failed to download file(s)!!!
echo Please select another installation method
pause
goto nocdrom

:nocdrom4
if not exist XMSXXXX0 goto end
command /k localize 9.1
goto nocdrom

:name_chk
for %%x in ( %number% ) do if exist FDCD000%%x goto medium5
for %%x in ( SHSU-CDH ) do if exist %%x goto medium5
for %%x in ( SHSU-CDR ) do if exist %%x goto medium5
rem if drivesrc==true goto medium5
goto nocdrom

:medium5
rem SHSUCDX initialisation
shsucdx /L:0
if "%errorlevel%"=="255" shsucdx /QQ /D7 /D:?DUMMYDEV
set counter=0
goto nextcd


:nextcd
if "%counter%"=="7" goto cdmodule
ADD %counter% 1 > nul
set counter=%errorlevel%
if not exist FDCD000%counter% goto nextcd
if not "%CPUTYPE%"=="80386" goto addcdrom
if not exist XMSXXXX0 goto addcdrom
goto loopbuff

:loopbuff
xmssize -1
if "%errorlevel%"=="0" goto addcdrom
if exist FDCD000%counter% DEVLOAD /H /Q CDRCACHE.SYS FDCD000%counter% CDRCACH%counter%1024
rem if non-zero errorlevel, we could decide to no longer execute
goto addcdrom

:addcdrom
if exist CDRCACH%counter% shsucdx /QQ /D:?CDRCACH%counter%,D
if not exist CDRCACH%counter% shsucdx /QQ /D:?FDCD000%counter%,D
goto nextcd


:cdmodule
set cdlimit=0
shsucdx /L:0
if "%errorlevel%"=="255" goto changecd
if "%errorlevel%"=="0" goto changecd
set cdlimit=%errorlevel%
goto cdreset

:cdreset
set drv_list=
set counter=0
goto drv_loop

:drv_loop
if "%counter%"=="%cdlimit%" goto changecd
add %counter% 1 > nul
set counter=%errorlevel%
shsucdx /L:%counter%
goto newdrive

:newdrive
if errorlevel 27 goto drv_loop
for %%x in ( D E F G H I J K L M N O P Q R S T U V W X Y Z ) do if errorlevel H%%x set adddrive=%%x
set drv_list=%drv_list% %adddrive%
CDD %adddrive%:\
set finaldir=%adddrive%:\FREEDOS
set adddrive=
goto testdisk

:testdisk
cls
if not "%user_dir%"=="" set finaldir=%user_dir%
set user_dir=
for %%x in ( %finaldir%\SETUP\BATCH\AUTORUN.BAT %finaldir%\PACKAGES\COPYING ) do if not [=exist %%x goto findISO
CDD %finaldir%\SETUP\BATCH\AUTORUN.BAT
for %%x in ( 0 %number% ) do SET CDNAME%%x=
for %%x in ( 0 %number% ) do SET drv_src%%x=
for %%x in ( label virtualcd number extfiles delay counter finaldir ) do set %%x=
for %%x in ( NUL CDRCACH1 ) do if exist %%x set result=%%x
ECHO S > %result%
set result=
pause
AUTORUN.BAT
goto end

:findISO
for %%x in ( %_CWD% %_CWD%FREEDOS\ %_CWD%DATA\ %_CWD%DATA\FREEDOS\ ) do if exist %%xFREEDOS.ISO set isofile2=%%xFREEDOS.ISO
for %%x in ( %_CWD% %_CWD%FREEDOS\ %_CWD%DATA\ %_CWD%DATA\FREEDOS\ ) do if exist %%xFDBOOTCD.ISO set isofile2=%%xFDBOOTCD.ISO
if "%isofile2%"=="" goto drv_loop
shsucdrd /F:%isofile2%
if not exist SHSU-CDR shsucdhd /F:%isofile2%
rem if "%errorlevel%"=="255" goto drv_loop
shsucdx /D:?SHSU-CDR,D /D:?SHSU-CDH,D
echo Errorlevel from ISOfile %isofile2% : %errorlevel%
set isofile2=
goto newdrive

:changecd
echo SETUP detected %cdlimit% cdromdrive(s)
if not "%cdlimit%"=="0" echo (driveletters assigned: %drv_list% )
if not "%cdlimit%"=="0" echo ..but none containing a FreeDOS installation disk.
echo 1) Return to overview screen to select another installation method
if not "%cdlimit%"=="0" echo 2) Let me insert my FreeDOS disk instead of the currently found disk(s).
if not "%cdlimit%"=="0" echo q) I'll use this cdrom instead, give me commandline access to it.
if "%cdlimit%"=="0" echo q) Abandon all hope, ye who enter here
set counter=
choice /N /C:12q Make your choice:
if errorlevel 3 goto manualcd
if errorlevel 2 goto cdreset
set drivesrc=
goto usrdelay

:manualcd
if "%cdlimit%"=="0" goto end
shsucdx /L:0
if errorlevel 255 goto end
for %%x in ( %drv_list% ) do if errorlevel H%%x set lastdrv=%%x:
cdd %lastdrv%\
set lastdrv=
cls
echo To manually continue FreeDOS setup, enter FreeDOS removable medium into drive
echo and type one of the following to continue SETUP (Depending on which drive
echo exactly you inserted the disk into):
for %%x in ( %drv_list% ) do echo %%x:\FREEDOS\SETUP\BATCH\AUTORUN
goto end


:medium2
localize 6.0
set /p user_dir=(Example: C:\FREEDOS) :
if "%user_dir%"=="" goto usrdelay
for %%x in ( a a: a:\ A A: A:\ ) do if "%user_dir%"=="%%x" set inputsrc=A:
for %%x in ( b b: b:\ B B: B:\ ) do if "%user_dir%"=="%%x" set inputsrc=B:
for %%x in ( A: B: ) do if "%inputsrc%"=="%%x" goto medium1
for %%x in ( ZIP LSM ) do if not exist %user_dir%\*.%%x goto usrdelay
rem diskette installation.
set inputsrc=%user_dir%
goto medium1

:medium3
set virtualcd=
localize 6.2
set /p medium=[location]:
for %%x in ( %medium%\*.* %medium%\*.ISO %medium%*.iso %medium%\FDBOOTCD.ISO %medium% ) do if exist %%x set virtualcd=%%x
goto mountiso

:mountiso
if "%virtualcd%"=="" goto nomedium
if exist %virtualcd% SHSUCDHD /F:%virtualcd%
if exist SHSU-CDH set drivesrc=true
if exist SHSU-CDH goto USERMENU
goto nomedium
:medium1
set copycmd=/y
localize 7.1
set dest=A:\FREEDOS
if not "%WHO%"=="" goto skipsrc
if not "%inputsrc%"=="" CDD %inputsrc%
CD \
if "%_CWD%"=="C:\" set dest=%inputsrc%
if not "%dest%"=="%inputsrc%" set dest=C:\TEMP
goto skipsrc
:skipsrc
if not exist %dest%\nul MD %dest%
a:\freedos\tunz -o %filedrv%\freedos\install.zip %dest%\
CDD %dest%
if "%inputsrc%"=="" set inputsrc=A:
install.bat %inputsrc%
goto end
:nocdrom2
cls
if not exist A:\driver\SHRDRV86.EXE goto drv_menu
%lh% A:\driver\SHRDRV86 /D:200k
cls
if "%errorlevel%"=="255" goto drv_menu
if "%errorlevel%"=="0" goto drv_menu
for %%x in ( A B C D E F G H I J K L M N O P Q R S T U V W X Y Z ) do if errorlevel H%%x set extradrv=%%x:
for %%x in ( MD CDD ) do %%x %extradrv%\USERFILE
COPY %COMSPEC% %extradrv%\COMMAND.COM
SET COMSPEC=%extradrv%\COMMAND.COM
goto drv_menu
:drv_menu
for %%x in ( 2 0 3 4 0 5 6 7 ) do localize 7.%%x
if "%usrinput%"=="" goto driver
goto load_drv
:driver
set label=
if exist $ATAMGR$ localize 8.1
if exist SCSIMGR$ localize 8.2
for %%x in ( %number% ) do if exist FDCD000%%x localize 8.3 (FDCD000%%x)
for %%x in ( 0 4 5 6 7 8 9 0 ) do localize 8.%%x
for %%x in ( filename args endfile thisdir usrinput ) do set %%x=
set /P usrinput=[(file+load-options+)ENTER] :
goto testfile
:testfile
if "%label%"=="" set label=driver
cls
if "%usrinput%"=="" goto usermenu
for %%x in ( %usrinput% ) do if "%filename%"=="" set filename=%%x
if not exist %filename% goto drv_menu
devload /Q %usrinput%
for %%x in ( %number% ) do if exist %cdname%%x% set drivesrc=true
if not "%extradrv%"=="" goto load_drv
goto %label%


:load_drv
CDD %filename%
set thisdir=%_CWD%
if not exist %_CWD%NUL set thisdir=%_CWD%\
for %%x in ( *.* ) do if "%thisdir%%%x"=="%filename%" set endfile=%%x
if "%endfile%"=="" goto %label%
ctty nul
copy %thisdir%%endfile% %extradrv%\USERFILE\%endfile%
ctty con
CDD -
for %%x in ( %usrinput% ) do if not "%filename%"=="%%x" set args=%args% %%x
for %%x in ( %endfile% ) do set %%x=%args%
for %%x in ( cdlimit args endfile usrinput thisdir filename usrinput virtualcd ) do set %%x=
goto %label%
:END
set label=init
REM if "%fdisklvl%"=="6" localize 9.2 @@@ No harddisk detected!
echo.
REM alias setup=%0\\

Recent Changes (All) | Edit SideBar Page last modified on October 11, 2005, at 01:10 PM Edit Page | Page History
Powered by PmWiki