Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

get cd-rom Volumename

0 views
Skip to first unread message

Stalkie

unread,
Aug 6, 2001, 3:36:10 PM8/6/01
to
Hi,

I would like to put the cd-rom volumename in a variabele and then use this
variabele to check if it matches with a hardcoded list.

If a match was found then a specific batch file should be executed.

I've tried a few things in autoexec.bat
but i can't get the volumename of my cd-rom. Getting the harddisk or
floppydisk volumename is not a problem.
(i used a program DPV but this doesn't work for my cd-rom drive)

All suggestions are welcome

Many thanks,
Michiel

William Allen

unread,
Aug 7, 2001, 2:34:22 AM8/7/01
to
Stalkie wrote in message

> Hi,
>
> I would like to put the cd-rom volumename in a variabele and then use this
> variabele to check if it matches with a hardcoded list.
>
> If a match was found then a specific batch file should be executed.
>
> I've tried a few things in autoexec.bat
> but i can't get the volumename of my cd-rom. Getting the harddisk or
> floppydisk volumename is not a problem.
> (i used a program DPV but this doesn't work for my cd-rom drive)

I'm assuming you know the drive letter of your CD-ROM, and
that there is a CD in the drive, and that you merely want to
load to Volume Name of that CD into a variable.

The simplest way is to use Inception = creating a batch file
with the name of the first word on another line of other output.

Inception is language dependent, so you _must_ translate the words
I use from the system output into your local system language.

For example, suppose my CD-ROM drive is E: and I have a CD in
the drive with Volume Name DIDO

When I type the command:
VOL E:

I see the output:
C:\WORK>vol E:

Volume in drive E is DIDO
Volume Serial Number is 20DB-34AC

C:\WORK>

If I write that output to a temporary file TMP.BAT like this:
VOL E:>TMP.BAT

I now have a file consisting of those lines. If I run TMP.BAT
as a batch file, it tries to run the command "VOLUME"

If I make sure there is a file called VOLUME.BAT in the
same folder, then the first line of TMP.BAT will pass control
to VOLUME.BAT with the five parameters:
in drive E is DIDO

Notice that DIDO (the volume name) is the 5th parameter.

So, if I make VOLUME.BAT consist of
SET VN=%5

then TMP.BAT will pass control to VOLUME.BAT and VOLUME.BAT
will set VN to the fifth word, which is the volume name.

Check the output line in your system, use whatever is the FIRST
word (the inceptive term) for the batch name (where I've used VOLUME.BAT)
and count up to the word that is the actual volume name (it may not
be the fifth in your system). Then use your count instead of the 5
I've used. Also note that to ECHO %5 literally into a file, you need
to use %%5 to stop the symbol being interpreted.

Put all that together and you get:
====Begin cut-and-paste (omit this line)
@ECHO OFF
VOL E:>TMP.BAT
ECHO. SET VN=%%5>VOLUME.BAT
FOR %%F IN (CALL DEL) DO %%F TMP.BAT
DEL VOLUME.BAT
ECHO.Volume name is %VN%

====End cut-and-paste (omit this line)
To use the code above, cut-and-paste the text between the ==== lines
into a file with extension .BAT and base name of your choice. Lines
that don't begin with two spaces have wrapped in transmission.

In the above, change E: to your CD drive letter. Count words in the output
of the VOL command and use the correct word where I've used the 5th
(your volume name may not be the 5th word). If your system doesn't
output the word "Volume" as the first word, use whatever word you
see for the base name of VOLUME.BAT

--
William Allen


0 new messages