CDROM environment variable

G

Guest

What is the environment variable for the CDROM. I am
needing to link data to info on a CD and that drive
letter changes from machine to machine.
 
P

Phil Robyn

What is the environment variable for the CDROM. I am
needing to link data to info on a CD and that drive
letter changes from machine to machine.

There isn't an environment variable for the CDROM, but
you can set one yourself:

=====begin C:\cmd\TEST\getcdrom.cmd ====================
1. @echo off
2. setlocal
3. for %%a in (d e f g h i j k l m n o p q r s t u v w x y z) do (
4. chkntfs %%a: | find "cdrom" >nul&&set CDROM=%%a:
5. )
6. if [%1]==[.] echo %CDROM%
7. endlocal&set %~n0=%CDROM%&goto :EOF
=====end C:\cmd\TEST\getcdrom.cmd ====================

C:\cmd>getcdrom .
d:

C:\cmd>set getcdrom
getcdrom=d:
 
P

Pegasus \(MVP\)

What is the environment variable for the CDROM. I am
needing to link data to info on a CD and that drive
letter changes from machine to machine.

There is no environmental variable to indicate the drive letter
for your CD ROM. You could use Google to locate a tool
that tells you if a given drive letter relates to a hard disk,
a CD drive or a networked drive. Alternatively you could
use the batch file below. It will identify the highest registered
drive letter - very often this is the drive letter for the CD ROM.

Reg.exe comes with the WinNT Resource Kit, and can
probably be downloaded freely from some Microsoft site.

@echo off
for /F "tokens=2" %%a in ('reg query hklm\system\mounteddevices ^| find /i
"DosDevices" ^| sort') do set x=%%a
for /F "tokens=2 delims=\" %%a in ('echo %x%') do set CDDrive=%%a
echo The CD is probably on drive %CDDrive%.
 

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