|
|
|
Help with Batch File
|
Original Message
|
Name: MissMe
Date: January 4, 2007 at 06:47:57 Pacific
Subject: Help with Batch FileOS: xphomeCPU/Ram: 3.0/512Model/Manufacturer: Medion |
Comment: 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.
Report Offensive Message For Removal
|
|
Response Number 1
|
Name: mitchell311
Date: January 4, 2007 at 10:14:18 Pacific
|
Reply: (edit)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%
Report Offensive Follow Up For Removal
|
|
Response Number 2
|
Name: mitchell311
Date: January 4, 2007 at 10:18:17 Pacific
|
Reply: (edit)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
Report Offensive Follow Up For Removal
|
|
Response Number 3
|
Name: MissMe
Date: January 5, 2007 at 04:12:01 Pacific
|
Reply: (edit)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!
Report Offensive Follow Up For Removal
|
|
Response Number 4
|
Name: mitchell311
Date: January 5, 2007 at 04:31:48 Pacific
|
Reply: (edit)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.
Report Offensive Follow Up For Removal
|
|
Response Number 5
|
Name: MissMe
Date: January 5, 2007 at 06:32:12 Pacific
|
Reply: (edit)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.avi But 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.
Report Offensive Follow Up For Removal
|
|
Response Number 6
|
Name: IVO
Date: January 5, 2007 at 07:16:45 Pacific
|
Reply: (edit)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.
Report Offensive Follow Up For Removal
|
|
Response Number 7
|
Name: mitchell311
Date: January 5, 2007 at 10:01:14 Pacific
|
Reply: (edit)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.
Report Offensive Follow Up For Removal
|
|
Response Number 9
|
Name: MissMe
Date: January 6, 2007 at 08:14:39 Pacific
|
Reply: (edit)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.
Report Offensive Follow Up For Removal
|
|
Response Number 10
|
Name: Mechanix2Go
Date: January 7, 2007 at 02:05:52 Pacific
|
Reply: (edit)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
Report Offensive Follow Up For Removal
|
|
Response Number 11
|
Name: MissMe
Date: January 7, 2007 at 14:46:14 Pacific
|
Reply: (edit)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.
Report Offensive Follow Up For Removal
|
|
Response Number 12
|
Name: Mechanix2Go
Date: January 7, 2007 at 15:35:20 Pacific
|
Reply: (edit)You may need to put the player and the avi in the same dir and: cd \somepath player some.avi OR \some\player \myflix\some.avi ===================================== If at first you don't succeed, you're about average.M2
Report Offensive Follow Up For Removal
|
|
Response Number 13
|
Name: MissMe
Date: January 20, 2007 at 12:11:31 Pacific
|
Reply: (edit)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.
Report Offensive Follow Up For Removal
|
|
Response Number 14
|
Name: MissMe
Date: January 20, 2007 at 12:23:13 Pacific
|
Reply: (edit)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.
Report Offensive Follow Up For Removal
|
Use following form to reply to current message:
|
|

|