Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I am trying to write a batch file to open a player with an avi file loaded that will run from a CD drive.
All files including the Batch File will run from the CD drive. I've tried using:
"IF EXIST d:\player.exe Start d:\player.exe video.avi"for each drive letter, but that spits out an error message "no disc in drive d:" if there isn't a disc in that drive.
For those who have multiple CD drives I need the batch file to verify which drive the CD is in and then set the proper path to the player and video.
In the end I want to create an html menu that will have a link to the batch file to open the player with the video loaded.

MissMe
I know there are probably better ways to do this but what I do is search for a file that I put on the cd rom and it finds it and sets the cd rom to that letter. Here is the code I us. In the code you will see that I search for standard.txt which I put on the cd or dvds.
@echo off
for %%a in (C D E F G H I J K L M N O P Q R S T U V W X Y Z) do if exist %%a:\standard.txt set CDROM=%%a
echo Your CDROM is %CDROM%

Sorry,
I also went to put this line of code in as well. Then we you call the cd rom instead of using d:\player.exe you can use
%CDROM%:\player.exe

Thank you mitchell311. I tried your code and it worked great at playing the file and it's much easier to write that way than the way I was, but it still gives me a "no disc in drive.." error for multiple drives.
Does anyone know a way to avoid the error message? Is it impossible to check a drive without accessing the drive (which causes the error message)? I guess the question is, Is there a way to check if a drive is empty without actually accessing it?
The only other option that I can think of is asking the user to tell what drive letter it is and setting the CDROM to that letter, but that isn't practical. Some users wouldn't have a clue!

If you do an if statement and lets say search for a file (lets say standard.txt on the cdrom). If it does not find the file it will just close the batch file. I believe this way it would not come up with an error. The script would just end.

My original batch file is an if statment somthing like below.
IF EXIST d:\player.exe Start d:\player.exe d:\video.avi
IF EXIST e:\player.exe Start e:\player.exe d:\video.aviBut if there are two drives for instance, D: and E: and drive d: is empty and E: contains my disc, then it first checks d: and spits out the error then it will run from the e: drive. So the disc runs, but I think the error message might be confusing to users. It's probably not a huge issue, because I'm sure it would only happen to a handful of users.. but.. I'd like to get rid of the error message if I can.

Try this
Vol D: >Nul 2>&1
If not ErrorLevel 1 Start D:...
Vol E: >Nul 2>&1
If not ErrorLevel 1 Start E:...obviosly the code may be made more smart, but that is matter of style.

If you do an if statement and lets say search for a file (lets say standard.txt on the cdrom). If it does not find the file it will just close the batch file. I believe this way it would not come up with an error. The script would just end.

Is this batch on the CD?
=====================================
If at first you don't succeed, you're about average.M2

Yes the Batch File and all files will be on the CD. I will be linking to the batch file from a html page (also on the CD). I am planning to make the CD autorun to a html page containing directions and a menu. One of the links will call on the batchfile.

So you don't need a drive letter.
Use:
\somepath\player some.avi
=====================================
If at first you don't succeed, you're about average.M2

It is giving me trouble finding the file without a drive letter. It doesn't seem to work without it. I get an error that says the avi file is not found. It will open the player but gives me an error message for the avi file.

You may need to put the player and the avi in the same dir and:
cd \somepath
player some.aviOR
\some\player \myflix\some.avi
=====================================
If at first you don't succeed, you're about average.M2

Thank you everyone, for all your responses. I finally did get it to work. I had to have the drive letter (exact path) for the player and also for the avi file. It looked something like this...
If Exist f:\player.exe Start f:\player.exe f:\movie.avi
There was a bit more to it, but generally that was the main line.

Sorry, that was the main statement, but to avoid the error message I added some goto statements that checked for the file and if it didn't find it, it spit out an error message telling the user to browse the disk for the file.

![]() |
![]() |
![]() |

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