rem This is my actual autoexec.bat provided to Hans Salvisberg as a rem "real world" example of BOOT.SYS usage. It is the companion to rem my config.sys file provided separately. rem The fact that my chosen command processor is 4DOS (JP Software) rather rem than command.com makes this autoexec much easier to set up. rem The DR/MS DOS independence would have been very complicated, clumsy, rem and difficult without 4DOS. The autoexec file relies heavily upon rem 4DOS features to create a readable, maintainable structure. rem A key feature of the style is the use of common subroutines to do things rem which are repeated for each configuration such as loading TSRs and rem setting variables. rem Any program names, etc., which happen to be trademarks are, of course, the rem property of their owners. rem No copyright is claimed, but acknowledgment of my authorship would be rem appreciated in any copies or derivative works. rem Raymond P. Tackett (CIS 76416,276) @echo off c:\bootbeta\boot SET /X if errorlevel 10 pause mode con: rate=32 delay=1 goto %boot% rem ********************************************************************** rem * NORMAL OPERATION * rem ********************************************************************** :normal :as400 gosub prebtm cls loadbtm on gosub postbtm if not isalias in alias /R %compath%aliases.500 60 unset compath if "%boot%" == "AS400" goto doas400 gosub edset iff %_ansi == 0 then prompt $h$P$g else gosub setpromp endiff goto exit rem ********************************************************************** rem * WINDOWS 3 * rem ********************************************************************** :windows gosub prebtm cls loadbtm on gosub postbtm if not isalias in alias /R %compath%aliases.500 unset compath win3\ win echo 15 seconds to reboot, Q to quit inkey /w15 %%x if "%@upper[%x]" == "Q" quit reboot goto exit rem ********************************************************************** rem * AS/400 * rem ********************************************************************** :doas400 dos6fix to %pcs inkey /W15 Use folders? (y/N/q) %%folder iff "%folder" ne "" then set folder=%@upper[%folder] else set folder=N endiff if %folder eq Q quit inkey /W15 Use printer? (y/N/q) %%printer iff "%printer" ne "" then set printer=%@upper[%printer] else set printer=N endiff if %printer eq Q quit inkey /W15 Use PC Support? (y/N/q) %%pcspt iff "%pcspt" ne "" then set pcspt=%@upper[%pcspt] else set pcspt=N endiff if %pcspt eq Q quit 25 uv oldengl cls uvcolors blue uv /s call nofolder echo 15 seconds to reboot, Q to quit inkey /w15 %%x if "%@upper[%x]" == "Q" quit reboot goto exit rem ********************************************************************** rem * VANILLA * rem ********************************************************************** :vanilla path c:\ramdisk;%path% goto vanexit rem ********************************************************************** rem * TEST JUNK * rem ********************************************************************** :test gosub cdpath tape\ quit rem ********************************************************************** rem * BACKUPS * rem ********************************************************************** :backups loadbtm on gosub cdpath gosub setramd gosub postbtm if not isalias in alias /R %compath%aliases.500 unset compath prompt BACKUPS $P$g tape\ goto exit rem ********************************************************************** rem * END OF BOOT ALTERNATIVES * rem ********************************************************************** :exit quit rem ********************************************************************** rem * COMMON SUBROUTINES * rem ********************************************************************** rem PREBTM rem rem Do everything that needs to be done before loadbtm on :prebtm gosub cdpath gosub setramd %ramd% gosub tsrload return rem POSTBTM rem rem Do common set after loadbtm on :postbtm gosub setvars gosub ramspec return rem TSRLOAD rem rem Key features: rem TSRs and their resident sizes are on a single list. rem Specifics for each are isolated to one place. rem The load syntax adjusts itself for the memory manager rem in use (even if there isn't one!). rem :tsrload rem Set up for memory manager specifics. iff "%mgr" == "QEMM" then set lh=%[drp]loadhi /b set sqz=/sqf set res=/res= elseiff "%mgr" == "MAX" then set lh=g:\386max\386load set lhp=PROG= set sqz=FLEXFRAME set res=size= elseiff "%mgr" == "DOS" then set lh=lh else rem no memory manager in use endiff rem Load the TSRs from list. Sizes line up below each TSR. Below sizes rem are configurations under which to load (bootyes) and not to rem load (bootno). set tsrlist=fast uv dmp files kstack 4dos24h prtsc mode1 mode2 set sizlist=32768 19972 14176 5072 1184 2240 384 512 512 set bootyes=all all none all all all all all all set bootno=none windows windows windows windows windows windows windows windows set hiload=yes yes yes yes yes yes yes yes no set squeeze=yes yes no no no no no no no set count=0 rem Top of the loading loop :tsrloop rem Use the 4DOS @word function to pick off the parameters for a TSR set tsl=%@word[%count,%tsrlist] rem Check for end of loop. Note that a hard coded count value is NOT used. rem All we do is see if we're off the end of the string. if "%tsl%" == "" goto tsrexit rem Not off the end of the world yet, pick up the reasons NOT to load ... set yes=%@upper[%@word[%count,%bootyes]] set no=%@upper[%@word[%count,%bootno]] rem ... and see if any of the reasons not to load are true. if "%yes" ne "%@upper[%boot]" .and. "%yes" ne "ALL" goto tsrbump if "%no" eq "%@upper[%boot]" goto tsrbump rem Use the TSR's logical name from tsrlist to call the appropriate rem subroutine for the command line switches. The subroutine also rem has the right to return an empty string as a signal not to load. gosub %tsl rem Check the "don't load" signal (empty command string) if "%tsc" == "" goto tsrbump rem Set up the resident size portion of the load high command, if any. iff "%res%" ne "" then set ressiz=%@word[%count,%sizlist] else set ressiz= endiff rem load a tsr with sleaze to minimize environment size -- QEMM workaround rem set the squeeze parameter iff "%@upper[%@word[%count,%squeeze]]" == "YES" then set sqp=%sqz% else set sqp= endiff rem save the command we want to do iff "%@upper[%@word[%count,%hiload]]" == "NO" then echo %tsc% > load.cmd else echo %lh% %sqp% %res%%ressiz% %lhp%%tsc% > load.cmd endiff rem save all the variables set > envsave rem clear out everything unset * rem do the command straight from the file %@line[load.cmd,0] rem restore the variables set /r envsave rem TSRBUMP loop increment point whether we loaded anything or not :tsrbump set count=%@eval[%count + 1] goto tsrloop :tsrexit if exist load.cmd erase /q load.cmd if exist envsave erase /q envsave unset mgr sqz res lh lhp ressiz yes no tsc sqp squeeze >& NUL unset tsrlist sizlist bootyes bootno count hiload >& NUL return rem rem %TSL SUBROUTINES (TSR PROGRAM SPECIFICS) rem :UV set tsc=g:\uv\uv.com return rem :PRTSC set tsc=g:\uv\prtsc.com page return rem :DMP set tsc=%drp%dmp /COM2 R9600 WCTS /T+ /G+ /MXP /MX:4 /D%ramd% return rem :FILES set tsc=%drp%files +80 return rem :KSTACK set tsc=%drp%kstack.com return rem :4DOS24H set tsc=%drp%4dos24h return rem :FAST rem Check for another cache loaded .OR. a signal from config.sys rem to load FAST! iff "%cache" eq "" .or. "%cache" eq "FAST" then set cache=FAST set con=f:\fastbeta\fast E set coff=f:\fastbeta\fast D set tsc=f:\fastbeta\fastx C:2048 HK:OFF P:0 SWB:8 S T:1 XMS else rem If a cache is already loaded, signal "no load" for this betazoid set tsc= endiff return rem :MODE1 rem Use the 4DOS @search command to scan the path for the correct MODE.COM rem (MS-DOS or DR-DOS). PATH is set correctly in config.sys for the DOS rem in use. set tsc=%@search[mode] com2:96,N,8,1,B return rem :MODE2 set tsc=%@search[mode] lpt2=com2 return rem rem FIND RAMDISK AND SET RAMD rem :setramd rem The last disk letter which is ready, not removable, and not remote rem is the ramdisk (or the last HD partition which will serve as the rem logical ramdisk if a driver is not loaded. set work=ZYXWVUTSRQPONMLKJIHGFEDC rem Start with the last drive. set count=%@index[%work,%_lastdisk] iff count lt 0 then rem last drive is a diskette (A or B) set ramd=%_boot\ramdisk goto ramdexit endiff :ramdloop set foo=%@substr[%work,%count,1]: rem Find highest drive letter that isn't a removable Bernoulli or CD-ROM. rem Allow for possible future networking as well. iff %@ready[%foo] == 1 .and. %@removable[%foo] == 0 .and. %@remote[%foo] == 0 then set ramd=%foo rem Copy everything to the ramdisk. pushd ramdisk copy *.* %ramd% /s /q >& NUL popd unset work count foo goto ramdexit else set count=%@eval[%count+1] endiff iff %count lt 24 then goto ramdloop else rem This whole process fell apart for some reason. rem Fail gracefully, but warn the user. pause SETRAMD processing failed to find a disk! set ramd=%_boot:\ramdisk unset count work foo goto ramdexit endiff :ramdexit return rem SET CDPATH :cdpath rem The object of the game is to end up with CDPATH set to: rem C:\;D:\ set work=CDEFGHIJKLMNOPQRSTUVWXYZ set count=1 set cdpath=C:\ :cdloop set d=%@substr[%work,%count,1]: rem if beyond last OR beyond end of %work string if %d gt %_lastdisk: .or. "%d" == ":" goto cdexit set cdpath=%[cdpath];%d\ set count=%@eval[%count+1] goto cdloop :cdexit unset work count d return rem SET PROMPT rem This part is horrendously complicated and mostly unnecessary, but rem the end result looks pretty. rem :setpromp rem prompt $P$g^return^rem test code iff "%_ansi" ne "1" then prompt $P$g^quit endiff iff %_shell == 0 then *set n=Primary else *set n=Shell: $z endiff if "%mr"=="" *set mr=512 if "%me"=="" *set me=64 if "%mx"=="" *set mx=1024 set a=$e[s$e[1;1f$e[0;0;34;47m$e[K$e[1;`%%@int[%%@eval[(%%_columns-74)/2]]`f $t $b $D $b set b=$e[0;0;34;47m RAM:`%%@dosmem[K]`K set c= $b$e[0;0;34;47m EMS:`%%@ems[K]`K set d= $b$e[0;0;34;47m XMS:`%%@xms[K]`K set e= $b `%%[n]`$e[u$e[0;0;37;44m$P$g prompt %[a]%[b]%[c]%[d]%[e] unset a b c d e return rem SET STANDARD VARIABLES rem This could be done faster via set /r. Personal preference at work! rem I'd rather maintain it here than in a separate file. rem :setvars if "%cspec" ne "" (set comspec=%cspec ^ unset cspec) set temp4dos=%ramd%\ set temp=%ramd%\ set tmp=%ramd%\ set pktmp=%ramd%\ set uv=%ramd%\ path %ramd%\;.;%path return rem PUT COMSPEC ON RAMDISK :ramspec copy %comspec% %ramd% set comspec=%ramd\%@name[%comspec].%@ext[%comspec] return rem SET EDITOR DU JOUR rem This part is also unnecessary for most users, but I fool around with rem different text editors sometimes and I just want to type "edit " rem no matter what editor I'm playing with at the moment. All the different rem editors I might use (including three not listed here) are set up with rem identical key/mouse mappings. :edset rem there's an alias named EDIT which uses %ed to decide what to use rem set ed=g:\boxer\b.exe rem set BOXER=-b -c -dg:\boxer -j -k0 -r -s -4 -6 -7 pushd me set ed=%[_cwds]me popd set me_dflt=/KN return rem EXIT POINT FOR TOTAL VANILLA :vanexit