Computing.Net > Forums > Disk Operating System > How to find CD-ROM letter in batch file?

How to find CD-ROM letter in batch file?

Reply to Message Icon

Original Message
Name: DH
Date: January 5, 2002 at 13:07:34 Pacific
Subject: How to find CD-ROM letter in batch file?
Comment:

I need to find the cd-rom letter in a x.bat file in order to use some command (%cdrom%:, cd .. etc). Is this possible? How?
Thanks!
DH


Report Offensive Message For Removal


Response Number 1
Name: The Doofus
Date: January 5, 2002 at 15:57:32 Pacific
Subject: How to find CD-ROM letter in batch file?
Reply: (edit)

Simply add %CDROM%:\ to your enviroment Variable

SET PATH=%CDROM%:\

or

PATH=%CDROM%:\

Example:

PATH=A:\;C:\;%CDROM%:\


Report Offensive Follow Up For Removal

Response Number 2
Name: The Doofus
Date: January 5, 2002 at 16:12:53 Pacific
Subject: How to find CD-ROM letter in batch file?
Reply: (edit)

Of course, once the enviroment variable is set you can call the unknown CDROM drive letter like any other:

xcopy %CDROM%:\stuff\something.txt c:\user


Report Offensive Follow Up For Removal

Response Number 3
Name: The Doofus
Date: January 5, 2002 at 16:14:43 Pacific
Subject: How to find CD-ROM letter in batch file?
Reply: (edit)

Ya never know if or how this board will word wrap. The above is all one line, 'natch.


Report Offensive Follow Up For Removal

Response Number 4
Name: Liquidice
Date: January 5, 2002 at 22:49:29 Pacific
Subject: How to find CD-ROM letter in batch file?
Reply: (edit)

I don't think he meant that. He means it would be able to work on any computer... like %SystemRoot%. I think thats one of them... anyway... call something and have it return the letter of the first cd-rom, without knowing the letter. See?

Keith


Report Offensive Follow Up For Removal

Response Number 5
Name: DH
Date: January 6, 2002 at 01:57:38 Pacific
Subject: How to find CD-ROM letter in batch file?
Reply: (edit)

Yes, Keith, this is the problem.
In WinXP, the default current folder is somewhere in %disk_system%\Documents and Settings… or who knows where…
In WinMe… In Win98… so…
I need that a particular CD with a very simple interface can be used on any computer (with Windows). I made a HTML interface with links to some HTML pages and to some EXE files. For the EXE files, I need to change the default folder to the application folder.
I prefer to use a BAT file to launch the EXE, but I don’t know how can I find the CDROM drive letter (in a BAT file) to use it in a sequence like that:
%cdrom%:\
cd xxx\yyy
app.exe
How can I put in the variable “cdrom” the cdrom letter?
Thanks to all!


Report Offensive Follow Up For Removal


Response Number 6
Name: The Doofus
Date: January 6, 2002 at 09:55:28 Pacific
Subject: How to find CD-ROM letter in batch file?
Reply: (edit)

Well, here ya go. It's a bit rough around the edges, so you'll probably want to tweak it. Right-click and "Save Target As" to avoid line wrapping:
findcd.txt

Credit to:
Charles Dye
Bill James
Tom Lavedas
Rob van der Woude


Report Offensive Follow Up For Removal

Response Number 7
Name: DH
Date: January 6, 2002 at 18:57:41 Pacific
Subject: How to find CD-ROM letter in batch file?
Reply: (edit)

For The Doofus
Thanks. I did it. But...

WinMe

Too many parameters - ˇ
Too many parameters
Invalid drive specificat
Bad command or file name
Bad command or file name


WinXP

The syntax of the command is incorrect.
The system cannot find the file specified.
Error occurred while processing: D:\WINDOWS\TEMP.\CDROM1.TMPˇDATEˇFIND.
The system cannot find the path specified.
']ˇCHOICE' is not recognized as an internal or external command,
operable program or batch file.
']ˇCHOICE' is not recognized as an internal or external command,
operable program or batch file.

Tomorrow, in 98.


Report Offensive Follow Up For Removal

Response Number 8
Name: The Doofus
Date: January 6, 2002 at 21:58:43 Pacific
Subject: How to find CD-ROM letter in batch file?
Reply: (edit)

TMPˇDATEˇFIND = wierd code page stuff going on. Open the original text file in DOS Edit and then Save As findCD.bat. That should strip the code page formatting.


Report Offensive Follow Up For Removal

Response Number 9
Name: DH
Date: January 8, 2002 at 18:17:00 Pacific
Subject: How to find CD-ROM letter in batch file?
Reply: (edit)

To The Doofus.
Thanks!!!


Report Offensive Follow Up For Removal

Response Number 10
Name: Greg
Date: March 5, 2002 at 11:39:24 Pacific
Subject: How to find CD-ROM letter in batch file?
Reply: (edit)

The link to the text file above is no longer working, does anyone have a copy of it? Thanks!!


Report Offensive Follow Up For Removal

Response Number 11
Name: KScripts
Date: March 21, 2002 at 22:27:32 Pacific
Subject: How to find CD-ROM letter in batch file?
Reply: (edit)

NT,2K,XP

C:\>for /f "tokens=3 delims=\:" %%k in ('reg query hklm\system\mounteddevices^|findstr /C:"5C003F00"') do set CDROM=%%k:
C:\>@echo %cdrom%\
E:\
C:\>



Report Offensive Follow Up For Removal

Response Number 12
Name: KScripts
Date: March 21, 2002 at 22:40:56 Pacific
Subject: How to find CD-ROM letter in batch file?
Reply: (edit)

I should have mentioned:
use %k instead %%k unless running from within a batch.

C:\>for /f "tokens=3 delims=\:" %k in ('reg query hklm\system\mounteddevices^|findstr /C:"5C003F00"') do set CDROM=%k:


Report Offensive Follow Up For Removal






Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: How to find CD-ROM letter in batch file?

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software




How often do you use Computing.Net?

Every Day
Once a Week
Once a Month
This Is My First Time!


View Results

Poll Finishes In 2 Days.
Discuss in The Lounge