First post, by RJDog
I'm not sure if anyone else might find this useful, but I developed this because it was useful to me. Like many, I'm sure, I have games or applications which require certain drivers or TSRs loaded before executing (i.e. network stack, VBE driver, SoftMPU, etc.) that I don't want to necessarily always load on system startup so that they always take up precious memory. Yes, I could have different startup configurations, driven by a config.sys menu system, but I personally don't care for that. I would rather load things dynamically as I need them.
Obviously the easiest way is to create a batch file to load the game which also loads the required TSR/driver (e.g. a DUKE3D.BAT which loads the S3VBE20 driver, then executes DUKE3D.EXE), but my problem with that basic method is that I could have multiple games that use the same TSR/driver, and/or if I run the same game multiple times, that means attempting to load the TSR/driver multiple times. Of course, this usually isn't a problem, as the TSRs/drivers are usually smart enough to recognize that they're already loaded in memory and just quit gracefully with some sort of error message, but for some reason that still wasn't good enough for me. I wanted a method to load a (set of) TSR/drivers on demand after boot, but also only once since last system boot.
So, without further ado, the Require-Once batch script (REQUIRE1.BAT):
@ECHO OFFIF NOT [%1]==[] GOTO check_dirsecho.echo Require1 Usage: REQUIRE1 command [options]echo command can be either:echo clean - (literal string) to initialize Require1 (call from AUTOEXEC.BAT)echo {batch command name} - name of a batch file in %REQUIRE_ONCE% directoryecho (without .BAT extension) to be called only onceecho since REQUIRE1 is called with "clean"echo options can be:echo quiet - (literal string) don't announce stuffecho.echo Example:echo Assuming C:\DOS\REQUIRE1\NETWORK.BAT exists, Require1 can be called asecho follows to call the script only once since Require1 was last called withecho the "clean" command:echo.echo REQUIRE1 NETWORKecho.GOTO end:check_dirsIF [%TEMP%]==[] SET TEMP=C:\TEMPIF [%REQUIRE_ONCE%]==[] SET REQUIRE_ONCE=C:\DOS\REQUIRE1IF NOT EXIST %TEMP%\NUL MKDIR %TEMP%IF NOT [%1]==[clean] GOTO regular_execute:clean_upIF NOT [%2]==[quiet] ECHO Initializing Require1. Deleting temp files.IF EXIST %TEMP%\*.R1 DEL %TEMP%\*.R1GOTO end:regular_executeIF EXIST %REQUIRE_ONCE%\%1.BAT GOTO command_okIF NOT [%2]==[quiet] ECHO Command Batch Not Found.GOTO end:command_okIF EXIST %TEMP%\%1.R1 GOTO subsequent_run:first_runIF NOT [%2]==[quiet] ECHO First run for %1. Running batch.CALL %REQUIRE_ONCE%\%1.BATECHO 1 > %TEMP%\%1.R1GOTO end:subsequent_runIF NOT [%2]==[quiet] ECHO Subsequent run for %1. Batch command not run.GOTO end:end
It essentially works by creating temporary .R1 files as markers to note that a particular script has been run already and, as noted in the usage output, the script expects to be run with the 'clean' parameter on boot to delete any .R1 temporary files left over from last time, leaving a clean slate.
To go along with this, then, you might have a script like this (C:\DOS\REQUIRE1\S3VBE.BAT):
@ECHO OFFC:\DOS\DRIVERS\S3VBE20 /INSTALL
and then (DUKE3D.BAT):
@ECHO OFFCALL C:\DOS\REQUIRE1\REQUIRE1.BAT S3VBEDUKE3D.EXE
It is by no means thoroughly tested, but it seems to work well for my needs (on MS-DOS 6.22). Anyway, I had fun making it if only for the thought exercise, and hopefully it's handy to someone else too.