Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I have a batch file that runs great as long as the CD is in the D:\ drive. However, I cannot assume that the CD-ROM drive will always be D:\. Does anyone know the commands to detect which drive it is and then how to assimilate it into my batch to run files from that drive when needed? The commands need to work for 95/98/2k/xp if possible.
ie.
:TWO
CALL "D:\WORKSTATION.BAT"
GOTO END:ONE
CALL "D:\SERVER.BAT"Thank you for your help.

Please list your current batch file here.
I made a batch file over the weekend that does just that.
It sets the CD-ROM to a variable and then sets the path to it.
Without seeing the current file to edit it would be rough.
Are you in windows when running the BAT or booting to a boot disk?

The batch is an auto install. It always runs from CD-ROM. Howver, I currently call all CD-ROM "D". In reality, the CD-ROM could be "E" or "F". I am trying to figure out what command I can use to run files through my batch no matter the CD-ROM drive letter. My full starting batch is below:
@ECHO OFF
COPY D:\AUTO\CHOICE.COM C:\WINNT
COPY D:\AUTO\CHOICE.COM C:\WINDOWS
CLS
@echo OFF
echo ************************************
echo * *
echo * 1. SERVER INSTALL *
echo * 2. WORKSTATION INSTALL *
echo * 3. CANCEL *
echo * *
echo ************************************
CHOICE /N /C:123 PICK A NUMBER (1, 2, OR 3)%1IF ERRORLEVEL ==3 GOTO END
IF ERRORLEVEL ==2 GOTO TWO
IF ERRORLEVEL ==1 GOTO ONE:TWO
CALL "D:\WORKSTATION.BAT"
GOTO END:ONE
CALL "D:\SERVER.BAT":END
pauseI want to replce "D:\..." with a command that will determine within the running batch which drive has the correct file and continue working. Please feel free to email me if you need more inof. nlentz@ddinet.com.

It would probably be a good idea to make a windows 98 boot disk, then look what they've done with the autoexec.bat.. it has dynamic drive letters based to determine a valid cd rom drive. it uses the variable %CDROM%:\ instead of D:\

I am figuring that you are running this from within windows being there isnt a MSCDEX in your BAT file.
Easy way to get around this is to set the CD-ROM to a variable by using a file on the CD.Lets say there is a file on the CD named CD.ID
In your batch file add lines for
set CDROM=NONE
If exist d:\CD.ID set CDROM=D:
If exist e:\CD.ID Set CDROM=E:
If exist f:\CD.ID set CDROM=F:
Path=CDROM@ECHO OFF
COPY %CDROM%\AUTO\CHOICE.COM C:\WINNT
COPY %CDROM%\AUTO\CHOICE.COM C:\WINDOWS
CLS
@echo OFF
echo ************************************
echo * *
echo * 1. SERVER INSTALL *
echo * 2. WORKSTATION INSTALL *
echo * 3. CANCEL *
echo * *
echo ************************************
CHOICE /N /C:123 PICK A NUMBER (1, 2, OR 3)%1IF ERRORLEVEL ==3 GOTO END
IF ERRORLEVEL ==2 GOTO TWO
IF ERRORLEVEL ==1 GOTO ONE:TWO
CALL "WORKSTATION.BAT"
GOTO END:ONE
CALL "SERVER.BAT":END
(Notice the use of %CDROM% for files that are on the CD in subdirectories. For anything on the root of the CD your path is already set.)
If your booting to DOS you can always set your CD-ROM to a drive letter with MSCDEX in autoexec.bat.
MSCDEX.EXE /D:mscd001 /L:X
(will set your CD-ROM to X:, If you have 2 they will be X: and Y: and you will still have to set a variable to the CD-ROM as the above if there is more then 1 CD-ROM)

![]() |
Strange PING issues
|
Site problem-revisited - ...
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |