• Please review our updated Terms and Rules here

BAT file

evildragon

Veteran Member
Joined
May 29, 2007
Messages
1,646
Location
Tampa Florida
I can't seem to find how to do this.. Tried searching but got nowhere.

I have all of my autoexec.bat commands go to my D: drive, as my D: drive is where everything is.

Though, sometimes I may not want my D: drive on (it's an external), and instead of my computer booting saying a crap load of Bad command or file names, and Invalid Directory, I want autoexec.bat to first check for the presense of the D: drive.

If the d: drive is there, then it can go on, but if it's not there, I want it to just end auto exec immediately.

EDIT: I tried for this one, but it seems to be for if the drive already has a letter, but no disk.. Mine either has a letter or not.
http://snippets.dzone.com/posts/show/4141
 
Last edited:
Try this:

@echo off
ctty nul
%comspec% /f /c dir d: | find "Directory of "
ctty con
if errorlevel==0 if not errorlevel==1 goto _isready
echo Drive D: is NOT ready
goto _end
::
:_isready
echo Drive D: is ready
goto _end
::
:_end

Timo Salmi's BATCH Tricks is an excellent read.
http://lipas.uwasa.fi/~ts/http/http2.html, search for "tsbat.zip"
 
I like Andy's solution, but how bout:

IF EXIST D:\
D:\AUTOEXEC.BAT

(Worth a try).

--T
This one would boot and work if the drive was on, but if the drive was off, it would then say "Invalid drive specification" then show the C: prompt.

I'm going to try the other one.

Try this:

@echo off
ctty nul
%comspec% /f /c dir d: | find "Directory of "
ctty con
if errorlevel==0 if not errorlevel==1 goto _isready
echo Drive D: is NOT ready
goto _end
::
:_isready
echo Drive D: is ready
goto _end
::
:_end

Timo Salmi's BATCH Tricks is an excellent read.
http://lipas.uwasa.fi/~ts/http/http2.html, search for "tsbat.zip"
Even though the most complicated batch file I ever used, it not only worked great, but I understood it too. I put all important loads in the D: drive area, and put DATE/TIME past the end. So either way, it asks for date and time, and if the drive is there, it loads what's on it. (and put the HD enclosures driver before the whole thing).

Thanks.
 
Last edited:
Back
Top