FINDVOL
Version 1.03
FINDVOL is a DOS command program that is intended to locate a logical disk drive by searching for its VOLUMEID.
FINDVOL 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.
FINDVOL will ignore remote (network) logical drives.
FINDVOL has been tested with Win 98 using floppy disk drives, IDE hard disk drives, Microsoft RAMDRIVE, SCSI ZIP drive.
Usage:
findvol [-a<drive> | -b<drive>] [-e] [-l<drive>] [-v<volid>] [-z]
where:
-a specifies that search starts after the specified drive;
-b specifies that search begins at the specified drive;
-e update environment variable;
-l specifies the last drive searched;
-v specifies the (case sensitive) volume id (default is MS-RAMDRIVE); and
-z silent mode.
In the case of the -a, -b, and -l switches, only the first character following the switch is used by FINDVOL, it is safe to use a longer string, additional characters will be ignored by FINDVOL.
|
Return Code |
Without -e switch |
With -e switch |
|
0 |
Not used |
Volume found |
|
1 - 26 |
Drive id A - Z |
Not used |
|
252 |
Volume not found |
Volume not found |
|
253 |
Not used |
Env ptr problem |
|
254 |
Invalid parameters |
Invalid parameters |
|
255 |
DOS version <4 |
DOS version <4 |
Table 1 FINDVOL return codes
If the -e switch is specified and FINDVOL locates the desired logical drive, FINDVOL will search its parent's environment table for a variable FINDVOL 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).
FINDVOL signals exceptions using return codes which can be tested using the errorlevel batch file statement. When used without the -e switch, FINDVOL also signals the identity of the located volume using return codes.
FINDVOL return codes are shown in Table 1
device=a:\himem.sys
devicehigh=a:\ramdrive.sys
/E 8000 512 128
Figure 1 Example CONFIG.SYS
@ECHO OFF
rem find the
ramdrive
set FINDVOL=.
findvol -e -z
if errorlevel 1
goto nord
set
TEMP=%FINDVOL%:\
set TMP=%TEMP%
rem setup
command.com to operate from the ramdrive
copy command.com
%FINDVOL%:\
set
comspec=%FINDVOL%:\command.com
rem expand the
selfextracting archive to the ramdrive
ami %FINDVOL%:\
path=%FINDVOL%:\bin;%FINDVOL%:\dos
%FINDVOL%:
amidiag
goto end
:nord
echo .
echo Cannot find
RAMDRIVE
echo .
set
:end
Figure 2 Example 1 AUTOEXEC.BAT
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.
FINDVOL 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.
FINDVOL 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 FINDVOL.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 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=%FINDVOL%:\
set TMP=%TEMP%
rem setup
command.com to operate from the ramdrive
copy command.com
%FINDVOL%:\
set
comspec=%FINDVOL%:\command.com
rem expand the
selfextracting archive to the ramdrive
ami %FINDVOL%:\
path=%FINDVOL%:\bin;%FINDVOL%:\dos
%FINDVOL%:
amidiag
goto end
:nord
echo .
echo Cannot find
RAMDRIVE
echo .
set
:end
Figure 3 Example 2 AUTOEXEC.BAT
FINDVOL is copyright Owen Duffy, 1999. All rights reserved.
Conditional on acceptance of all conditions set out in this document, a license is hereby granted for non-commercial use of FINDVOL V1.01.
This software and accompanying files and documentation are provided "as is" and without warranties as to performance or merchantibility or any other warranties whether express or implied. No warranty of fitness for a particular purpose is offered.
@echo off
set FINDVOL=
FINDVOL -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 FINDVOL=%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 4 Example 2 FINDRAMD.BAT
No part of the FINDVOL package, software or documentation may be distributed without explicit prior written permission of the copyright holder.
The latest FINDVOL distribution can be obtained from http://www.owenduffy.net/findvol.htm .
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.
5 September 2003