borris111698
asked on
locating the CD Rom
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
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
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.
ASKER
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
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.
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.
YOu can also ask the user for this information, using PROMPT and ASK.
Alex
Alex
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.