VOGONS


First post, by JediSword

User metadata
Rank Newbie
Rank
Newbie

Hi. I'm trying to do universal MS-DOS boot floppy (mainly to use with LiveCD images)

CD will be mounted with:

LH=A:\DOSDRV\SHSUCDX.COM /D:BANANA /L:R

My idea is to put in autoexec bat line that run START.BAT file only if this file exists on CD.

But this:

IF EXIST R: R:\START.BAT call R:\START.BAT

gives me Abort, Retry Fail if disc is not inserted.

So is any way to detect if CD is inserted?
Thanks for advance

Reply 1 of 8, by JediSword

User metadata
Rank Newbie
Rank
Newbie

oh, wrong paste:
should be:

IF EXIST R:\START.BAT call R:\START.BAT

Reply 2 of 8, by JediSword

User metadata
Rank Newbie
Rank
Newbie

I found little tool called DREADY.COM in REMOVED:

DREADY <drive> [/W] Version 2.2 (c) 1997, Horst Schaeffer option /W tests: READY to WRITE? errorlevel 0:ready, 1:read only (/W), […]
Show full quote

DREADY <drive> [/W]
Version 2.2 (c) 1997, Horst Schaeffer
option /W tests: READY to WRITE?
errorlevel 0:ready, 1:read only (/W), 2:not ready, 255:invalid

but unfortunately this code:

DREADY R:
if ERRORLEVEL 0 GOTO AUTOSTARTCD
if ERRORLEVEL 1 GOTO AUTOSTARTCD
GOTO END
:AUTOSTARTCD
echo autostart
IF EXIST R:\START.BAT call R:\START.BAT>NUL

always jumps to :AUTOSTARTCD which gives me Abort-Retry-Fail if drive not inserted

Last edited by DosFreak on 2024-07-07, 17:34. Edited 1 time in total.

Reply 3 of 8, by DaveDDS

User metadata
Rank Oldbie
Rank
Oldbie
JediSword wrote on 2024-06-21, 14:42:
I found little tool called DREADY.COM in REMOVED: […]
Show full quote

I found little tool called DREADY.COM in REMOVED:

DREADY <drive> [/W] Version 2.2 (c) 1997, Horst Schaeffer option /W tests: READY to WRITE? errorlevel 0:ready, 1:read only (/W), […]
Show full quote

DREADY <drive> [/W]
Version 2.2 (c) 1997, Horst Schaeffer
option /W tests: READY to WRITE?
errorlevel 0:ready, 1:read only (/W), 2:not ready, 255:invalid

but unfortunately this code:

DREADY R:
if ERRORLEVEL 0 GOTO AUTOSTARTCD
if ERRORLEVEL 1 GOTO AUTOSTARTCD
GOTO END
:AUTOSTARTCD
echo autostart
IF EXIST R:\START.BAT call R:\START.BAT>NUL

always jumps to :AUTOSTARTCD which gives me Abort-Retry-Fail if drive not inserted

if ERRORLEVEL value ....
performs ... if ERRORLEVEL is >= value

so your IF are out of order - the first one will go if ERROELVEL==1
but even that won't work - ERRORLEVEL will always be >= 0
so the GOTO will always get taken.

I think you want something like: (not tested)

DREADY R:
if ERRORLEVEL 2 goto end
echo AutoStart
if exists R:\START.BAT call R:\START.BAT
:end

Dave ::: https://dunfield.themindfactory.com ::: "Daves Old Computers"->Personal

Last edited by DosFreak on 2024-07-07, 17:34. Edited 1 time in total.

Dave ::: https://dunfield.themindfactory.com ::: "Daves Old Computers"->Personal

Reply 5 of 8, by myne

User metadata
Rank Oldbie
Rank
Oldbie
DaveDDS wrote on 2024-06-21, 14:59:
if ERRORLEVEL value .... performs ... if ERRORLEVEL is >= value […]
Show full quote
JediSword wrote on 2024-06-21, 14:42:
I found little tool called DREADY.COM in REMOVED: […]
Show full quote

I found little tool called DREADY.COM in REMOVED:

DREADY <drive> [/W] Version 2.2 (c) 1997, Horst Schaeffer option /W tests: READY to WRITE? errorlevel 0:ready, 1:read only (/W), […]
Show full quote

DREADY <drive> [/W]
Version 2.2 (c) 1997, Horst Schaeffer
option /W tests: READY to WRITE?
errorlevel 0:ready, 1:read only (/W), 2:not ready, 255:invalid

but unfortunately this code:

DREADY R:
if ERRORLEVEL 0 GOTO AUTOSTARTCD
if ERRORLEVEL 1 GOTO AUTOSTARTCD
GOTO END
:AUTOSTARTCD
echo autostart
IF EXIST R:\START.BAT call R:\START.BAT>NUL

always jumps to :AUTOSTARTCD which gives me Abort-Retry-Fail if drive not inserted

if ERRORLEVEL value ....
performs ... if ERRORLEVEL is >= value

so your IF are out of order - the first one will go if ERROELVEL==1
but even that won't work - ERRORLEVEL will always be >= 0
so the GOTO will always get taken.

I think you want something like: (not tested)

DREADY R:
if ERRORLEVEL 2 goto end
echo AutoStart
if exists R:\START.BAT call R:\START.BAT
:end

Dave ::: https://dunfield.themindfactory.com ::: "Daves Old Computers"->Personal

No. The original script is correct.
The dready command just isn't working properly.

Op
Try manually from c:
Dready r:
What happens?

If it works try if errorlevel 0 echo blah
What happens?

Last edited by DosFreak on 2024-07-07, 17:36. Edited 1 time in total.

I built:
Convert old ASUS ASC boardviews to KICAD PCB!
Re: A comprehensive guide to install and play MechWarrior 2 on new versions on Windows.
Dos+Windows 3.11+tcp+vbe_svga auto-install iso template
Script to backup Win9x\ME drivers from a working install
Re: The thing no one asked for: KICAD 440bx reference schematic

Reply 6 of 8, by DaveDDS

User metadata
Rank Oldbie
Rank
Oldbie

>>if ERRORLEVEL value ....
>>performs ... if ERRORLEVEL is >= value

>No. The original script is correct.
>The dready command just isn't working properly.

Using this little program to set ERRORLEVEL: ERR.C
#include <stdio.h>
main(int argc, char *argv[])
{
if(argc == 2) exit(atoi(argv[1]));
}
and this batch file: TST.BAT
@echo OFF
ERR %1
if errorlevel 5 echo 5
if errorlevel 4 echo 4
if errorlevel 3 echo 3
if errorlevel 2 echo 2
if errorlevel 1 echo 1
if errorlevel 0 echo 0
-- I get these resulte --
R:\> TST 0
0
R:\> TST 1
1
0
R:\> TST 3
3
2
1
0
R:\> TST 5
5
4
3
2
1
0
R:\>

As you can see, "if ERRORLEVEL" works as I described, and "echo 0" is
performed in EVERY case... So I don't see how the original code:

>>>DREADY R:
>>>if ERRORLEVEL 0 GOTO AUTOSTARTCD
>>>if ERRORLEVEL 1 GOTO AUTOSTARTCD

could go anywhere BUT AUTOSTARTCD

Above tested under DOS5 and DosBox (same output)

Dave ::: https://dunfield.themindfactory.com ::: "Daves Old Computers"->Personal

Dave ::: https://dunfield.themindfactory.com ::: "Daves Old Computers"->Personal

Reply 7 of 8, by myne

User metadata
Rank Oldbie
Rank
Oldbie

Oh, right. I forgot how much of a pita errorlevels are.

I built:
Convert old ASUS ASC boardviews to KICAD PCB!
Re: A comprehensive guide to install and play MechWarrior 2 on new versions on Windows.
Dos+Windows 3.11+tcp+vbe_svga auto-install iso template
Script to backup Win9x\ME drivers from a working install
Re: The thing no one asked for: KICAD 440bx reference schematic

Reply 8 of 8, by JediSword

User metadata
Rank Newbie
Rank
Newbie

If i write script.bat like that

@echo off
dready r:
if errorlevel 2 echo E2
if errorlevel 0 echo E0

I get:
when cd is ejected: E2 & E0
and when cd inserted: only E0

it's working correctly now, I think.

This is code I put in AUTOEXEC.BAT (on floppy image)

DREADY R:\
if ERRORLEVEL 2 GOTO END
IF EXIST R:\START.BAT call R:\START.BAT

And START.BAT can be like this (I'd like autoreboot when program exit, but keep ability to stay in DOS)

IF EXIST R:\PROGRAM.EXE call "R:\PROGRAM.EXE
ECHO Reboot in 3s (C=stay in DOS)
CHOICE /C:yc /T:y,03 /N
IF ERRORLEVEL 2 GOTO SKIP
if ERRORLEVEL 0 CALL FDAPM COLDBOOT
:SKIP
ECHO Welcome to MS-DOS
:END

FDAPM - power management tool from FreeDOS (this is only method I found to do full reboot. Other tools only restarts DOS and skips BIOS)
Also usefull with

LH=A:\DOSDRV\FDAPM.COM ADV:REG

in autoexec which limit CPU usage by DOS

Then CD can be created with ImgBurn