FINDDR Version 1.04

 

 

FINDDR is a DOS command program that is intended to locate a logical disk drive by searching for its VOLUMEID and / or a specified file.

Prefrequisites / limits / compatibility

FINDDR requires MS-DOS V4 or later. The -e command line switch uses undocumented features of DOS to update the parent's environment and may not work correctly with non Microsoft DOS or Windows NT.

 

FINDDR –e switch depends on chaining of the program segment prefix (PSP). This functionality is not provided under Windows NT if the parent is a 32-bit application. When an MS-DOS-based application starts from a single command shell (SCS), it inherits a new copy of environment variables. Any attempts by the application to modify its parent's environment variables are unsuccessful. When the application closes, the SCS is restored to its original state. If another MS-DOS-based application starts, none of the changes the first application made exist. However, if the parent is another MS-DOS-based application, environment variables can be modified by the child application and used by the parent. Therefor, if you enter the command COMMAND at the prompt in the DOS window, an additional command interpreter is started and FINDDR should work in this shell.

 

FINDDR will ignore remote (network) logical drives if volid is specified.

 

FINDDR has been tested with Win 98 using floppy disk drives, IDE hard disk drives, IDE ZIP drives, Microsoft RAMDRIVEs, SCSI ZIP drives, CDROMs.

Command line

Usage:

finddr [-a<drive> | -b<drive>] [-e] [-f<filepath] [-l<drive>] [-v<volid>] [-s | -z]

 

where:

-a  specifies that search starts after the specified drive;

-b  specifies that search begins at the specified drive (default C);

-e  update environment variable;

-f   specifies a file path (without drive specification);

-l   specifies the last drive searched (default Z);

-v  specifies the (case sensitive) volume id

-s  specifies simple output; and

-z  silent mode (ignored on free version).

 

In the case of the -a, -b, and -l switches, only the first character following the switch is used by FINDDR, it is safe to use a longer string, additional characters will be ignored by FINDDR.

 

At least one of filepath or volid must be specified. If both are specified, both criteria must be met. Normal DOS wildcards are acceptable in the filepath specification.

 

Note that:

 

Return Code

Without -e switch

With -e switch

0

Not used

Drive found

1 - 26

Drive id A - Z

Not used

252

Volume not found

Drive not found

253

Not used

Env ptr problem

254

Invalid parameters

Invalid parameters

255

DOS version <4

DOS version <4

Table 1 FINDDR return codes

 

If the -e switch is specified and FINDDR locates the desired logical drive, FINDDR will search its parent's environment table for a variable FINDDR and update the first character of the environment variable contents to the drive letter for the logical volume (further characters if present will not be changed).

Return codes

FINDDR signals exceptions using return codes that can be tested using the errorlevel batch file statement. When used without the -e switch, FINDDR also signals the identity of the located volume using return codes.

 

FINDDR return codes are shown in Table 1

 

device=a:\himem.sys

devicehigh=a:\ramdrive.sys /E 8000 512 128

Figure 1 Example 1 CONFIG.SYS

 

@ECHO OFF

rem find the ramdrive

set FINDDR=.

finddr -e -vMS-RAMDRIVE -z

if errorlevel 1 goto nord

set TEMP=%FINDDR%:\

set TMP=%TEMP%

 

rem setup command.com to operate from the ramdrive

copy command.com %FINDDR%:\

set comspec=%FINDDR%:\command.com

 

rem expand the selfextracting archive to the ramdrive

ami %FINDDR%:\

 

path=%FINDDR%:\bin;%FINDDR%:\dos

%FINDDR%:

 

amidiag

goto end

 

:nord

echo .

echo Cannot find RAMDRIVE

echo .

set

 

:end

Figure 2 Example 1 AUTOEXEC.BAT

 

Applications

There are time when one wants to boot a machine with a standalone (ie independent of the operating system installed on the machine) environment.

 

This may for instance be to run diagnostics, rescue packages, disk/image capture/restore, or just for standalone use of the machine for a specific application.

 

 If the stand alone environment does not fit entirely on a single floppy drive, one achieve the result by booting from the floppy and installing a RAMDISK, then expanding a compressed archive from the floppy to the RAMDISK and transferring control to the RAMDISK image.

 

FINDDR can be used to automatically locate the RAMDISK (whose drive letter will depend on existence of hard volumes) and pass that to the batch file environment to enable automation commands to expand the archive to the desired logical drive.

 

Examples

Example 1 - Using the environment variable

FINDDR is written in assembler for small program size, fitting in three disk sectors. The example below requires one sector for the config.sys, one sector for the autoexec.bat, and three for FINDDR.EXE, totalling just five sectors in addition to the boot environment. The example with a Win 98 minimum boot disk has 900KB free for a compressed archive, which should hold a 2MB to 4MB system (depending on the compression achieved).

Example 2 - Using only return codes

Example 2 uses return codes and a subsidiary batch file to process the return codes. It is less convenient, and messier, but it does not use any undocumented features and should therefore be more compatible.

 

@ECHO OFF

rem find the ramdrive

set LglDrv=27 * 26 Z 25 Y 24 X 23 W 22 V 21 U 20 T 19 S 18 R 17 Q 16 P 15

set LglDrv=%LglDrv% O 14 N 13 M 12 L 11 K 10 J 9 I 8 H 7 G 6 F 5 E 4 D 3 C

rem cls

call findramd.bat %LglDrv%

set LglDrv=

set TEMP=%FINDDR%:\

set TMP=%TEMP%

 

rem setup command.com to operate from the ramdrive

copy command.com %FINDDR%:\

set comspec=%FINDDR%:\command.com

 

rem expand the selfextracting archive to the ramdrive

ami %FINDDR%:\

 

path=%FINDDR%:\bin;%FINDDR%:\dos

%FINDDR%:

 

amidiag

goto end

 

:nord

echo .

echo Cannot find RAMDRIVE

echo .

set

 

:end

Figure 3 Example 2 AUTOEXEC.BAT

Example 3 - Using –s and set command under command extensions

 

 

@ECHO OFF

 

setlocal enableextensions

rem get the drive letter for the volume with label KEEPASS

set tf=%temp%\%random%%random%.TMP

finddr -vKEEPASS -s >%tf%

if errorlevel 252 goto nokeepass

 

set /p KD=<%tf%

echo %KD%:\keepass\keepass.exe %KD%:\keepass\owen.kdbx

start %KD%:\keepass\keepass.exe %KD%:\keepass\owen.kdbx

goto end

 

:nokeepass

echo Keepass drive not found

 

:end

set KD=

if exist %tf% del %tf%

Figure 4 Example 3

Supersedes

FINDDR supersedes FINVOL. It is command line parameter compatible, but there are two significant differences in its operation:

Copyright

FINDDR is copyright Owen Duffy, 1999. All rights reserved.

License

Conditional on acceptance of all conditions set out in this document, a license is hereby granted for non-commercial use of FINDDR V1.04.

Disclaimer of Warranty

This software and accompanying files and documentation are provided "as is" and without warranties as to performance or merchantability or any other warranties whether express or implied. No warranty of fitness for a particular purpose is offered.

 

@echo off

set FINDDR=

FINDDR -vMS-RAMDRIVE -z

if errorlevel 250 goto no_ramdrive

if not errorlevel 3 goto no_ramdrive

goto do_shift

 

:loop

if errorlevel %1 goto no_shift

 

:do_shift

shift

shift

if not %1*==* goto loop

goto no_ramdrive

 

:no_shift

set FINDDR=%2

goto end

 

:no_ramdrive

echo.

echo Unable to find RAMDRIVE. This may be because this computer has less than the 

echo minimum required extended memory. 

echo.

:end

Figure 5 FINDRAMD.BAT

Distribution

No part of the FINDDR package, software or documentation may be distributed without explicit prior written permission of the copyright holder.

 

It is good practice with all software to thoroughly test the software with non-critical data before forming an opinion on whether you will use it on more critical data. You must assume the entire risk for use of this software.

The user must assume the entire risk of using the program. The liability of the author will be limited to product replacement or refund of purchase price paid to the author.

 

28 June 2010


© Copyright: Owen Duffy 1995, 2021. All rights reserved. Disclaimer.