Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


locating the CD Rom

Posted on 1999-06-24
Medium Priority
Last Modified: 2013-12-03
When using batch file I want to copy a file from the cd rom to another directory... the problem is that the cd rom drive could be d:,e:,f: or something else.

I know that you can use the registry like %SystemRoot%/system is there a way to do this in a batch file to find the registered CD rom drive...

need a quick answer.... cheers
Question by:borris111698
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 22

Expert Comment

ID: 1401094
Batch files are DOS.  DOS doesn't "know" about windows or the registry.

What you can do is have a environmental variable defined that specifies the CD drive letter and then use that variable in your batch file.  You can set the environmental variable in the autoexec.bat file so that it will allways be set.  Of course, it has to be set manually there, then other batch files can use that setting.
LVL 22

Expert Comment

ID: 1401095
Another option is to write a win32 console program that takes a drive letter as a parameter and uses GetDriveType() to see if the drive is a CD rom.  Then it returns 0 if it is and non-zero if it is not.  The batch file can use this program with the IFERRORLEVEL statement to determine if a drive letter is for a CD ROM.

Author Comment

ID: 1401096
the batch file will use %SystemRoot%\system as in the %systemroot% is usually c:\windows... the batch file will run from a cd so there is no chance of changing the autoexec.bat file
Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

LVL 22

Expert Comment

ID: 1401097
If this is a batch file that is run repeatidly, you can change the autoexec once--manually to set the environent varaible.  Then your batch file can use it.

Or you can use my other suggestion, which is to write a win32 console program to help you.

DOS does not provide the information you want.
LVL 15

Expert Comment

ID: 1401098
YOu can also ask the user for this information, using PROMPT and ASK.


Accepted Solution

dnavarro earned 150 total points
ID: 1401099
You said that the batch file is running on the CD itself, right?

Then you can create a text file in the TEMP directory with the drive and directory that the batch file is running in using the CD command.

When you type "CD" with no parameters the current drive and directory are displayed.  This can be redirected to a file:

cd > %temp%\cd-drive
rem ** create new batch file
copy part1.dat + %temp%\cd-drive + part2.dat %temp%\runme.bat
call %temp%\runme.bat

or something along these lines.  

Featured Post

Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, I will show how to use the Ribbon IDs Tool Window to assign the built-in Office icons to a ribbon button.  This tool will help us to find the OfficeImageId that corresponds to our desired built-in Office icon. The tool is part of…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA.…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question