Computing.Net > Forums > Windows 2000 > Batch file help detecting CD-ROM

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Batch file help detecting CD-ROM

Reply to Message Icon

Name: Niki
Date: January 14, 2003 at 06:33:40 Pacific
OS: 2000
CPU/Ram: 1.8 GHZ intell/512 ram
Comment:

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.



Sponsored Link
Ads by Google

Response Number 1
Name: Johns
Date: January 14, 2003 at 07:17:41 Pacific
Reply:

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?


0

Response Number 2
Name: Niki
Date: January 14, 2003 at 13:57:29 Pacific
Reply:

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)%1

IF 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
pause

I 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.


0

Response Number 3
Name: Ad
Date: January 14, 2003 at 17:01:26 Pacific
Reply:

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:\



0

Response Number 4
Name: Johns
Date: January 15, 2003 at 07:47:05 Pacific
Reply:

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)%1

IF 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)


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


Strange PING issues Site problem-revisited - ...



Post Locked

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


Go to Windows 2000 Forum Home


Sponsored links

Ads by Google


Results for: Batch file help detecting CD-ROM

Running batch files from a cd www.computing.net/answers/windows-2000/running-batch-files-from-a-cd/36191.html

Windows 2000 & XP, wont detect CD ROM www.computing.net/answers/windows-2000/windows-2000-amp-xp-wont-detect-cd-rom/25561.html

Batch file help! www.computing.net/answers/windows-2000/batch-file-help/57105.html