autoexec.bat and ramdrive

autoexec.bat and ramdrive

Post by Berc » Sun, 27 Jul 2003 01:50:53



Hi,
At first: I'm sorry for my englisch!

Some time I need at the work a network Boot-CD with MS-Dos 7.03 (win98) and
some special-tools.
Now I want to use 4DOS (Version 7.05). 4DOS is in config.sys my first Shell
(SHELL=4dos.com /E:512 /P).

My problem with 4Dos is at this time to create a ramdrive. Here is a cut
from  AUTOEXEC.BAT :
____________________________________________________________________________
_______________
set rDrv=
\dos\FindRamD.EXE
For %%d 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
errorlevel H%%d set rdrv=%%d
If "%1"=="" goto ramda
echo
echo Fehler! Kein RAMDrive gefunden...
echo
goto END
:RamDa
set rDrv=%rdrv%:
set temp=%RDrv%\
set tmp=%RDrv%\
md %RDrv%\net
COPY q:\dos\net.cab %RDrv%\ >NUL
%RDrv%
cd \net
a:\dos\extract /e \net.cab >NUL
call a:\net\setNic
if not %nic%=="" con2srv
____________________________________________________________________________
_________________

When Command.Com from MS-DOS is my Shell, I haven't any Problems.
I think the Problem is the command "SET rDrv=%rdrv%:".
4DOS give me the error:
":" can't find
"IF" ....

Ok. when you can help me I'm very happy!

Thanks in advance.
Berco

 
 
 

autoexec.bat and ramdrive

Post by Klaus Meinhar » Sun, 27 Jul 2003 03:00:15


Hi Berco

Quote:> My problem with 4Dos is at this time to create a ramdrive. Here is a
> cut from  AUTOEXEC.BAT :
> set rDrv=\dos\FindRamD.EXE
> For %%d 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
> errorlevel H%%d set rdrv=%%d

I dont quite undestand that syntax. Linewapping doesn' help :-(

As far as I can see here you're setting the variable rdvr first to
some prog on your disk, then you have a line that expands to for ...if
errorlevel HZ set rdrv=Z (example, taking the last letter of the FOR
loop). AFAIR errorlevel is a numeric value.

Quote:> If "%1"=="" goto ramda

`%1`is the placeholder for the 1st commandline variable you used to
start your batch. Unprobable in autoexec.bat.

Quote:> set rDrv=%rdrv%:
> set temp=%RDrv%\

4DOS is not case-sensitive. The 3 variables above mean exactly the same.

Quote:> When Command.Com from MS-DOS is my Shell, I haven't any Problems.

I doubt that. But anyway: there is the ability to debug a 4dos batch.
Use SETDOS /Y1 as the 1st line of your batch, step through it line by
line and see what the lines expand to in crucial places and the value of
your vars. If you don't know what I'm talking about here, hit F1 at a
4dos prompt and take it from there...

--
Viele Grsse, best regards,

*Klaus Meinhard*
073657 East 530752 North
Author of the 4XBTM batch collection at
http://home.t-online.de/home/K_Meinhard/

 
 
 

autoexec.bat and ramdrive

Post by Stev » Sun, 27 Jul 2003 05:41:35



> Hi,
> At first: I'm sorry for my englisch!

> Some time I need at the work a network Boot-CD with MS-Dos 7.03 (win98) and
> some special-tools.
> Now I want to use 4DOS (Version 7.05). 4DOS is in config.sys my first Shell
> (SHELL=4dos.com /E:512 /P).

> My problem with 4Dos is at this time to create a ramdrive. Here is a cut
> from  AUTOEXEC.BAT :
> ...

 Whatever program creates the virtual disk drive, if it uses a known
label (e.g., "MS-RAMDRIVE" when you use any version of MS's RAMDRIVE.SYS
in your CONFIG.SYS), AND you do not use that label on any other
drive/partition, you can find the virtual drive in your AUTOEXEC.BTM
like this:






enddo
unset/q i v
echo No virtual disk found
goto VD_DONE

:FOUND_VD
...

:VD_DONE

The environment variable V will be set to the drive letter of the first
"MS-RAMDRIVE" found, or it will be unset.
You can replace the searched for disk label with whatever your virtual
disk driver generates.

The program segment is one I have been using for years. It works equally
well in 4DOS, 4NT, and Take Command.

--

Telephone: 856-354-1752            POB 1540, Cherry Hill, NJ 08034
-------------------------------------------------------------------

 
 
 

autoexec.bat and ramdrive

Post by Charles D » Sun, 27 Jul 2003 06:27:50



> Hi,
> At first: I'm sorry for my englisch!

> Some time I need at the work a network Boot-CD with MS-Dos 7.03 (win98) and
> some special-tools.
> Now I want to use 4DOS (Version 7.05). 4DOS is in config.sys my first Shell
> (SHELL=4dos.com /E:512 /P).

> My problem with 4Dos is at this time to create a ramdrive. Here is a cut
> from  AUTOEXEC.BAT :
> ____________________________________________________________________________
> _______________
> set rDrv=
> \dos\FindRamD.EXE
> For %%d 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
> errorlevel H%%d set rdrv=%%d
> If "%1"=="" goto ramda
> echo
> echo Fehler! Kein RAMDrive gefunden...
> echo
> goto END
> :RamDa
> set rDrv=%rdrv%:
> set temp=%RDrv%\
> set tmp=%RDrv%\
> md %RDrv%\net
> COPY q:\dos\net.cab %RDrv%\ >NUL
> %RDrv%
> cd \net
> a:\dos\extract /e \net.cab >NUL
> call a:\net\setNic
> if not %nic%=="" con2srv
> ____________________________________________________________________________
> _________________

> When Command.Com from MS-DOS is my Shell, I haven't any Problems.
> I think the Problem is the command "SET rDrv=%rdrv%:".
> 4DOS give me the error:
> ":" can't find
> "IF" ....

> Ok. when you can help me I'm very happy!

Using the traditional DOS device drivers RAMDRIVE.SYS or VDISK.SYS,
the RAMdisk is assigned the first available drive letter.  In other
words the drive letter is arbitrary, and will vary from system to
system.  You are faced with the problem of identifying the drive
letter assigned.  You might be tempted to use the FINDRAMD.EXE
program from the Windows 98 Emergency Boot Disk:

   findramd.exe
   iff errorlevel 255 then
      unset /q ram
      echo RAMdisk not found!
   else

      echo RAMdisk is drive %ram
   endiff

However, you should resist the temptation to use FINDRAMD.EXE.  It's
six kilobytes huge, and does nothing that can't be done just as well
by a few lines in a batch file:

   unset /q ram





   enddo
   unset /q i drv
   iff defined ram then
      echo RAMdisk is drive %ram
   else
      echo RAMdisk not found!
   endiff

Another approach is to abandon RAMDRIVE.SYS / VDISK.SYS and
substitute a third-party RAMdisk.  One very good alternative is
Franck Uberto's superior XMSDSK.EXE, which has the advantage of
allowing you to specify the desired drive letter on the command
line:

   set ram=R:
   xmsdsk %ram 8192 /y

XMSDSK also consumes less memory than RAMDRIVE.SYS and automatically
loads its code into upper memory if available.  On the down side,
it's larger than RAMDRIVE.SYS (20k versus 13k.)  Happily, each can
be packed using UPX:  XMSDSK.EXE packs to 12k, and RAMDRIVE.SYS to
a little over 5k.

Once your RAMdisk is created (and if need be, located) it can be
treated much like a small hard drive.  And as with a hard drive you
should probably create a directory structure, both for organization
and to conserve limited space in the root directory:

   md /n %ram\dos %ram\4dos %ram\temp

--

 
 
 

autoexec.bat and ramdrive

Post by Charles D » Sun, 27 Jul 2003 10:10:04



> Hi Berco

> > For %%d 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
> > errorlevel H%%d set rdrv=%%d

> I dont quite undestand that syntax. Linewapping doesn' help :-(

I suspect that that peculiar line is intended to exploit a known
defect in COMMAND.COM.  No sanity checking is done on the number
following IF ERRORLEVEL, so it's possible to pass it non-numerics.
Which pretty well demonstrates the whole difference of mindsets,
IMHO.

   4DOS user:  "I found a bug.  How quickly can we get it fixed?"

   COMMAND.COM user:  "I found a bug.  How can I exploit it?"

--

 
 
 

autoexec.bat and ramdrive

Post by Berc » Sun, 27 Jul 2003 18:59:53


Thank you for the fast help! It's works.


> Using the traditional DOS device drivers RAMDRIVE.SYS or VDISK.SYS,
> the RAMdisk is assigned the first available drive letter.  In other
> words the drive letter is arbitrary, and will vary from system to
> system.  You are faced with the problem of identifying the drive
> letter assigned.  You might be tempted to use the FINDRAMD.EXE
> program from the Windows 98 Emergency Boot Disk:

>    findramd.exe
>    iff errorlevel 255 then
>       unset /q ram
>       echo RAMdisk not found!
>    else

>       echo RAMdisk is drive %ram
>    endiff



 
 
 

autoexec.bat and ramdrive

Post by Charles Dy » Sun, 27 Jul 2003 22:48:57




Quote:>Thank you for the fast help! It's works.

I'm glad it's useful to you.

Here are a few other RAMdrive-related snippets which might be
helpful.  To use the RAMdrive for temporary and pipe files:

   md /n %ram\temp
   set temp=%ram\temp
   set tmp=%ram\temp

To move the 4DOS executable to the RAMdrive:

   md /n %ram\4dos
   copy %comspec %ram\4dos

If you have also put the help system on the RAMdrive by
copying 4HELP.EXE and 4DOS.HLP to the same directory, you
can make 4DOS look there first.  This requires that you
also have OPTION.EXE available:

   option //installpath=%ram\4dos

To prevent 4DOS from attempting to open the directory
database on drive C:, you can do:

   option //treepath=%ram\

A good executable packer which you can use to compress 4DOS,
saving space on your floppy and RAMdrive; be sure to brand
*before* compressing:

   http://upx.sourceforge.net/

An excellent third-party RAMdrive:

   ftp://garbo.uwasa.fi/pc/memutil/fu_rd19i.zip

A good compressing archiver which can make self-extracting
archives:

   ftp://ftp.sac.sk/pub/sac/pack/lhark04d.zip

--

 
 
 

autoexec.bat and ramdrive

Post by Kenny McCorma » Mon, 28 Jul 2003 05:34:26





>> Hi Berco

>> > For %%d 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
>> > errorlevel H%%d set rdrv=%%d

>> I dont quite undestand that syntax. Linewapping doesn' help :-(

>I suspect that that peculiar line is intended to exploit a known
>defect in COMMAND.COM.  No sanity checking is done on the number
>following IF ERRORLEVEL, so it's possible to pass it non-numerics.
>Which pretty well demonstrates the whole difference of mindsets,
>IMHO.

>   4DOS user:  "I found a bug.  How quickly can we get it fixed?"

>   COMMAND.COM user:  "I found a bug.  How can I exploit it?"

But what does the above *do*?
(I suppose that makes this OT in com4...)
 
 
 

autoexec.bat and ramdrive

Post by Charles Dy » Mon, 28 Jul 2003 13:17:20







>>> Hi Berco

>>> > For %%d 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
>>> > errorlevel H%%d set rdrv=%%d

>>> I dont quite undestand that syntax. Linewapping doesn' help :-(

>>I suspect that that peculiar line is intended to exploit a known
>>defect in COMMAND.COM.  No sanity checking is done on the number
>>following IF ERRORLEVEL, so it's possible to pass it non-numerics.
>>Which pretty well demonstrates the whole difference of mindsets,
>>IMHO.

>>   4DOS user:  "I found a bug.  How quickly can we get it fixed?"

>>   COMMAND.COM user:  "I found a bug.  How can I exploit it?"

>But what does the above *do*?
>(I suppose that makes this OT in com4...)

Imagine that you had to write a parser in assembly language which
would read a string of ASCII digits from a text file, and convert
to an 8-bit integer value.  That's one of the tasks IF ERRORLEVEL
has to perform.

In order to convert your ASCII string into an integer, you would
start by zeroing an accumulator to hold the result.  DOS exit
codes only go up to 255, so a single byte would suffice.  Either
an 8-bit register or a location in memory would be fine.

Next, you'd write a loop to read characters (digits, presumably)
from the file and modify your accumulator accordingly.  As you
read in each character, you'd check that it was in fact a digit,
and then you'd subtract 48 (decimal) from each one to convert
it from ASCII to its value.  (The character "0" has an ASCII
value of 48.)  Then you'd multiply the current contents of your
accumulator by 10 and add in the value of the digit you've just
read.  Perhaps you would check for overflows at this point.
Finally, you'd loop back for the next digit.  When you run out
of digits, you are done parsing the integer and your accumulator
contains the value that IF ERRORLEVEL is to compare the most
recent exit code against.

Now, let's imagine that you forgot to write the check for actual
ASCII digits, 48 through 57, and so your routine accepts other
characters as 'digits'.  How would it deal with a strange string
like, say, the "HC" in "IF ERRORLEVEL HC"?

Well:  your accumulator starts at zero.  The first 'digit', "H",
is ASCII character 72.  Subtract 48, and it gets a value of 24.
Multiply the accumulator by ten, add 24, and your working value
is 0*10+24 = 24.  The second 'digit', "C", is ASCII 67.  Subtract
48, and its value is 19.  Multiply the accumulator by ten and add
19, you get 24*10+19 = 259.  But wait, it's only eight bits and
has just overflowed!  Well, this is Microsoft, we don't check for
overflows; 259 mod 256 is 3.  The next character is a space, no
more digits, we're done parsing the integer.  IF ERRORLEVEL HC
works out to the same thing as IF ERRORLEVEL 3.

4DOS has its own quirks.  Rather than writing a special eight-bit
integer parser just for IF ERRORLEVEL, Rex chose to call some
existing, vastly more sophisticated numeric parser.  So instead
of writing IF ERRORLEVEL 3, you can say IF ERRORLEVEL 1048579 or
IF ERRORLEVEL 3.14159265358979323846 or even IF ERRORLEVEL -253.
Negative error codes, whooo -- shades of Macintosh!

--

 
 
 

autoexec.bat and ramdrive

Post by Stev » Mon, 28 Jul 2003 22:38:31



> ... IF ERRORLEVEL HC
> works out to the same thing as IF ERRORLEVEL 3.

Nice explanation!

Quote:

> 4DOS has its own quirks.  Rather than writing a special eight-bit
> integer parser just for IF ERRORLEVEL, Rex chose to call some
> existing, vastly more sophisticated numeric parser.  So instead
> of writing IF ERRORLEVEL 3, you can say IF ERRORLEVEL 1048579 or
> IF ERRORLEVEL 3.14159265358979323846 or even IF ERRORLEVEL -253.
> Negative error codes, whooo -- shades of Macintosh!

So what is the value used in JPware (I assume that 4NT and TC use the
same parser) from those comparisons? Is it equivalent to


or some other value?
--

Telephone: 856-354-1752            POB 1540, Cherry Hill, NJ 08034
-------------------------------------------------------------------

 
 
 

autoexec.bat and ramdrive

Post by Charles Dy » Mon, 28 Jul 2003 23:53:38


On Sun, 27 Jul 2003 09:38:31 -0400, "E. S. (Steve) Fabian"



>> 4DOS has its own quirks.  Rather than writing a special eight-bit
>> integer parser just for IF ERRORLEVEL, Rex chose to call some
>> existing, vastly more sophisticated numeric parser.  So instead
>> of writing IF ERRORLEVEL 3, you can say IF ERRORLEVEL 1048579 or
>> IF ERRORLEVEL 3.14159265358979323846 or even IF ERRORLEVEL -253.
>> Negative error codes, whooo -- shades of Macintosh!

>So what is the value used in JPware (I assume that 4NT and TC use the
>same parser) from those comparisons? Is it equivalent to


>or some other value?

Low eight bits of the integer portion, I would assume, for 4DOS.  4NT
and TC32 are probably not the same -- Windows error codes have some
wider range.  At any rate, one of the benefits of using professional
tools is that you *don't* have to muck around with such undocumented
internal tomfoolery....

--

 
 
 

autoexec.bat and ramdrive

Post by Kenny McCorma » Tue, 29 Jul 2003 01:07:00






...
>>But what does the above *do*?
>>(I suppose that makes this OT in com4...)

>Imagine that you had to write a parser in assembly language which
>would read a string of ASCII digits from a text file, and convert
>to an 8-bit integer value.  That's one of the tasks IF ERRORLEVEL
>has to perform.

Rest of good explanation clipped.

Very good.  The point of course being to be able to reuse the drive letters
as the errorlevels.  You've got to wonder what kind of sick mind it took to
figure that out originally... (*)

(*) It seems to me that it was probably somebody at MS who was familiar
with the code.

 
 
 

autoexec.bat and ramdrive

Post by Charles Dy » Tue, 29 Jul 2003 01:58:02




>Very good.  The point of course being to be able to reuse the drive letters
>as the errorlevels.  You've got to wonder what kind of sick mind it took to
>figure that out originally... (*)

I first saw it used in alt.msdos.batch by one Benny Pederson:  a
very pleasant and likable guy, though I feel no need to emulate his
scripting style.

--

 
 
 

1. autoexec.bat and understanding bat files

When one uses notepad.exe to open autoexec.bat, the document looks like a
software program code resembling BASIC.  

What does autoexec.bat do, and how can we use it or change it to do different
things?  How does autoexec.bat do its things?  Can we write new autoexec.bat
files with other names  (somethingsomething.bat) for any reason?

G C

2. sendmail 8.8.5 and relay

3. my autoexec.bat disapear

4. not recieved certificate yet!

5. adding line to autoexec.bat

6. Wireless email

7. Starting the autoexec.bat

8. Problem with PC-DITTO, 40 Mb ICD, DOS 4.0: Divide Overflow

9. * HELP NEEDED DESPERATELY FOR AUTOEXEC.BAT *

10. AUTOEXEC.BAT PROMPT

11. DIRCMD in autoexec.bat files...

12. 4DOS 5.0B not loading AUTOEXEC.BAT

13. DIRCMD in autoexec.bat files...