Obtain drive letter assignment of CD/DVD drive?

D

Dennis

2003 XP Pro up to date

Would like to process a batch file to run a series of programs and/or
copy/delete command lines.


Also, would like to have the 1) copy/paste files and 2) the batch
file(s) on a Read-only DVD.


Once I start the batch file, how can I detect the drive letter of the
respective user's CD/DVD drive and carry that variable through
subsequent batch file command lines. (Keep in mind, that my CD is Read

Only)


TIA


EagleOne
 
P

Pegasus \(MVP\)

This batch file will detect the drive letter of the first CD ROM:

Line1 @echo off
Line2 set Label=CD-ROM
Line3 set drive=
Line4
Line5 for /F %%a in ('fsutil fsinfo drives ^| find "\" ^| find /i /v
"Drives"') do fsutil fsinfo DriveType %%a | find /i "%Label%" > nul && (set
drive=%%a& goto Found)
Line6
Line7 echo No %Label% found
Line8 goto Exit
Line9
Line10 :Found
Line11 echo The %Label% is mounted on drive %drive%.
Line12
Line13 :Exit
Line14 echo Press the Space Bar to close this window.
Line15 pause > nul

Subsequent batch files can use the %drive% variable to refer
to the CD drive.

Do not retype this batch file - use copy & paste instead!
 
D

Dennis

Thank you for your time and knowledge!

This batch file will detect the drive letter of the first CD ROM:

Line1 @echo off
Line2 set Label=CD-ROM
Line3 set drive=
Line4
Line5 for /F %%a in ('fsutil fsinfo drives ^| find "\" ^| find /i /v
"Drives"') do fsutil fsinfo DriveType %%a | find /i "%Label%" > nul && (set
drive=%%a& goto Found)
Line6
Line7 echo No %Label% found
Line8 goto Exit
Line9
Line10 :Found
Line11 echo The %Label% is mounted on drive %drive%.
Line12
Line13 :Exit
Line14 echo Press the Space Bar to close this window.
Line15 pause > nul

Subsequent batch files can use the %drive% variable to refer
to the CD drive.

Do not retype this batch file - use copy & paste instead!
 
D

Dennis

Pegesus,

When I ran this batch file;
1) the Line references were not recognized
2) "did not recognized "Setdrive"
3) did not come up with a "%Label% variable

The exact batch filed used is:

*************************************************************
@echo off
set Label=CD-ROM
set drive=

for /F %%a in ('fsutil fsinfo drives ^| find "\" ^| find /i /v
"Drives"') do fsutil fsinfo DriveType %%a | find /i "%Label%" > nul &&
(setdrive=%%a& goto Found)

echo No %Label% found
goto Exit

:Found
echo The %Label% is mounted on drive %drive%.

:Exit
echo Press the Space Bar to close this window.
pause > nul

*************************************************************

Where did I go wrong?
EagleOne
 
P

Pegasus \(MVP\)

1) the Line references were not recognized
The line references are there so that you can tell where
each line starts, regardless of the way your news reader
might wrap long lines. You must omit them.

2) "did not recognized "Setdrive"
You unwrapped this line incorrectly. The command is
"set drive", with a space in between.

3) did not come up with a "%Label% variable
You defined %Label% yourself in the second line!

If you are unable to make it work then you must attach
your version of the batch file as an attachment to your
reply.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top