VOGONS


First post, by RJDog

User metadata
Rank Member
Rank
Member

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 OFF

IF NOT [%1]==[] GOTO check_dirs

echo.
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% directory
echo (without .BAT extension) to be called only once
echo since REQUIRE1 is called with "clean"
echo options can be:
echo quiet - (literal string) don't announce stuff
echo.
echo Example:
echo Assuming C:\DOS\REQUIRE1\NETWORK.BAT exists, Require1 can be called as
echo follows to call the script only once since Require1 was last called with
echo the "clean" command:
echo.
echo REQUIRE1 NETWORK
echo.
GOTO end

:check_dirs
IF [%TEMP%]==[] SET TEMP=C:\TEMP
IF [%REQUIRE_ONCE%]==[] SET REQUIRE_ONCE=C:\DOS\REQUIRE1
IF NOT EXIST %TEMP%\NUL MKDIR %TEMP%

IF NOT [%1]==[clean] GOTO regular_execute

:clean_up
IF NOT [%2]==[quiet] ECHO Initializing Require1. Deleting temp files.
IF EXIST %TEMP%\*.R1 DEL %TEMP%\*.R1
GOTO end

:regular_execute
IF EXIST %REQUIRE_ONCE%\%1.BAT GOTO command_ok
IF NOT [%2]==[quiet] ECHO Command Batch Not Found.
GOTO end

:command_ok
IF EXIST %TEMP%\%1.R1 GOTO subsequent_run

:first_run
IF NOT [%2]==[quiet] ECHO First run for %1. Running batch.
CALL %REQUIRE_ONCE%\%1.BAT
ECHO 1 > %TEMP%\%1.R1
GOTO end

:subsequent_run
IF 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 OFF
C:\DOS\DRIVERS\S3VBE20 /INSTALL

and then (DUKE3D.BAT):

@ECHO OFF
CALL C:\DOS\REQUIRE1\REQUIRE1.BAT S3VBE
DUKE3D.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.

Reply 1 of 2, by Jorpho

User metadata
Rank l33t++
Rank
l33t++

In theory, as long as you're running something that is visible with "mem /c", you could do something like this by using the DOS "FIND" command. Something like

MEM /C|FIND "s3vbe" & IF ERRORLEVEL 1 (
C:\DOS\DRIVERS\S3VBE20 /INSTALL
)
DUKE3D.EXE

But I'm not sure if I have the syntax right.

Reply 2 of 2, by RJDog

User metadata
Rank Member
Rank
Member
Jorpho wrote:

In theory, as long as you're running something that is visible with "mem /c", you could do something like this by using the DOS "FIND" command.

I thought of that as well.. I think my solution is more versatile, but this would be a much simpler solution. I will have to experiment with the FIND command...