View Full Version : Can you help to program an autoexec.bat file for DOS
Fotis_Greece
14th March 2004, 20:04
This must be very simple.
I have made a bootable CD which will bring up DOS boot from Windows 98. It's the same as the win98 boot diskette but I have altered a bit the config.sys and autoexec.bat files in order to add some more options instead of the typical Start the computer with CD support and Start with no cd support.
I have made an option to start norton ghost from the cd and it is working great. The only problem is that in the autoexec.bat file I have to specify the cd rom drive where ghost is located, in my PC the drive is D:
So it works with my PC but when I tried it in my friend's PC it didn't work because the drive letter of the CD rom is drive E:
So I would like to tell the autoexec.bat file to go to the directory of the first CD drive without having to specify the drive letter. In this way it will work in any PC.
Do you have any idea how to do it?
Fotis_Greece
14th March 2004, 20:09
Forgot to say you can have a look at the config.sys and autoexec.bat files.
get them from here
http://www.interchefs.com/club/dosfiles.zip
Brother John
15th March 2004, 00:14
Afaik there is no way to find out the letter of the first cd drive with pure batch scripting.
However you could extend your config.sys menu with a ghost entry for every drive letter
menuitem=GHOSTD, Start Ghost Environment From CD Drive D.
menuitem=GHOSTE, Start Ghost Environment From CD Drive E.
menuitem=GHOSTF, Start Ghost Environment From CD Drive F.
...
craigal
15th March 2004, 01:04
It looks like the environment variable CDROM is already set for you. I assume this is set by one of the drivers in the config.sys file
This variable is used in line 10 of the autoexec.bat to set the patch
path=%RAMD%:\;a:\;%CDROM%:\
You could use this to run the ghost program.
Cheers
Craig
Fotis_Greece
15th March 2004, 02:07
I did this
LH %ramd%:\MSCDEX.EXE /D:mscd001 /L:K
by using L:K it means that cd rom drive letters start from K. So there is no way to conflict with any other HDDs
mpucoder
15th March 2004, 04:48
Originally posted by Fotis_Greece
by using L:K it means that cd rom drive letters start from K. So there is no way to conflict with any other HDDs
That would conflict on one of my computers. Years ago my friend and I got tired of the ever-moving CD, especially with applications that create shortcuts to the drive (like visual studio if you don't want the samples and documentation on HD). Adding a HD later would break all the shortcuts, and we'd have to re-install.
To avoid any conflict, and so our machines were compatible, we decided to assign CD (and now DVD) drives from Z backward.
Fotis_Greece
15th March 2004, 06:43
So, should I assign L:Z? Since the last drive letter is this as specified in config.sys, does this mean that automatically all other cd rom drives will have backward letters?
By the way let me ask you something. I have also specified a menuitem there to start Ghost for example from my USB pen drive. Since all HDDs in my PC are NTFS (and therefore not recognizable) the pen drive gets the letter C: and so I have specified the letter C: in autoexec.bat
Of course that would not work in other PCs that have FAT drives as I guess the pen drive will get other available drive letter. Do you think there could be a solution to this.
mpucoder
15th March 2004, 13:27
No, the letters don't automatically get assigned in reverse order, we had to change the mscdex command if there were more. I don't know about the pen drive, or even how DOS can see it (unless the BIOS presents it as a drive).
Fotis_Greece
15th March 2004, 18:51
Ues, the BIOS presents the pen drive as hard disk
ppera2
15th March 2004, 19:44
It can be solved like this:
d:
if not errorlevel 0 goto CDisE
if exist ghost\ghost.exe goto Gho
:CDisE
e:
if not errorlevel 0 goto CDisF
if exist ghost\ghost.exe goto Gho
:CDisF
f:
if not errorlevel 0 goto CDisG
if exist ghost\ghost.exe goto Gho
:CDisG
g:
if not errorlevel 0 goto CDisH
if exist ghost\ghost.exe goto Gho
:CDisH
h:
if not errorlevel 0 goto CDisI
if exist ghost\ghost.exe goto Gho
:CDisI
i:
if not errorlevel 0 goto CDisJ
if exist ghost\ghost.exe goto Gho
:CDisJ
j:
if not errorlevel 0 goto err
:Gho
cd ghost
ghost.exe
:err
echo Unable to start Ghost
piscator
15th March 2004, 20:03
Originally posted by Fotis_Greece
This must be very simple.
<snip...>
So I would like to tell the autoexec.bat file to go to the directory of the first CD drive without having to specify the drive letter. In this way it will work in any PC.
Do you have any idea how to do it?
Actually, it is quite simple if you use 4DOS/4NT (http://www.jpsoft.com/) shell. I don't know how any decent batch programmer would go around not using this :D. With this shell you can use the variable function "@cdrom[driveletter]" to check if a drive is a cdrom drive.
For example, the following script displays all CDROM/DVD drives.
set drives=C: D: E: F: G: H: I: J: K: L: M: N: O: P: Q: R: S: T: U: V: W: X: Y: Z:
for %drive in (%drives%) (if %@cdrom[%drive%]==1 echo Drive %drive% is a CDROM-drive)
EDIT: to do specifically what you want, you can use the following script.
set drive=
do i = 67 to 90
if %@cdrom[%@char[%i]]==1 (set drive=%@char[%i] & leave)
&enddo
echo First CDRom dive is: %drive
greetz,
Piscator
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.