~Writing Your Own AUTOEXEC.BAT


By:  Simon Burrows  -and-  Alex Willmer


`After our great guide to writing your own CONFIG.SYS file in issue
`39 of Cheet Sheets, here's our promised guide aimed at tuning your
`AUTOEXEC.BAT.  As well as setting a few options, your AUTOEXEC.BAT
`is also  used to  automatically load  software such  as your mouse
`driver, memory-resident  virus  checker  etc.    As  before,  this
`document starts with some explanation and basic tips, then goes on
`to explain  individual lines  which  can  be  inserted  into  your
`AUTOEXEC.BAT.



~`                  *              *             *




~`                     
~`                     What is an AUTOEXEC.BAT?
~`                     


`Once your computer has finished looking through your CONFIG.SYS to
`load some  important device  drivers and memory options, then it's
`your turn  to tell  it what  you want  to do.   For  this you  use
`commands.   Instead of  having to  type all  the commands that you
`want each  time you  start your computer, you can put the commands
`into a  file called  AUTOEXEC.BAT.   This  is  a  text  file  with
`commands that  tell the  computer what to do.  The word 'AUTOEXEC'
`means 'AUTOmatically  EXECute' which  means  the  file  will  load
`itself each  time your  computer boots  itself up,  and the  'BAT'
`file-extention means  it is  a batch  file    (simply  because  it
`contains a batch of commands).




~`        
~`        What is a Batch File, and what does one look like?
~`        


`A simple batch file might contain the following lines :-


`     ECHO OFF
`     D:
`     CD\UTILS
`     INSTALL.EXE
`     C:
`     CD\GAMES


`As you  can see,  each line  of the  batch  file  has  a  separate
`command.  Each of these commands could also be typed separately at
`the DOS prompt, but by putting them all into a batch file, you can
`execute all  these commands  in turn  just by  running this  batch
`file.

`This particular  batch file  is called  INSTALL.BAT.  It tells the
`computer to  go to  drive D:, change to the \UTILS directory, then
`run the  file called  INSTALL.EXE.  When INSTALL.EXE finishes, the
`batch file  then tells  the computer to change the drive to C: and
`enter the \GAMES directory.

`Your AUTOEXEC.BAT  works in  exactly  the  same  way.    The  only
`difference is,  as I've  said, that  it runs  itself when you boot
`your machine  up.   Because your  AUTOEXEC.BAT is loaded once, and
`only once,  each time your computer is booted up, it will often be
`used to  load vital  software such  as your  mouse  driver,  virus
`checker, disk cacher etc.




~`                           
~`                           Safety First
~`                           


`Before you  do anything  to your  AUTOEXEC.BAT, you should back it
`up.  To do this, you first need to get to the directory containing
`this file.     This is done by entering the following two commands
`at the DOS prompt, each one with an [ENTER] press after it :-


`     C:
`     CD\


`This puts   you in  the root directory of your main hard-disk (the
`location of your AUTOEXEC.BAT).  Now you can type the following to
`make a back-up of your AUTOEXEC.BAT called AUTOEXEC.BAK :-


`     COPY AUTOEXEC.BAT AUTOEXEC.BAK


`Now it's   a very good idea to make a system-disk.  You don't have
`to do  this, but  it can  save a lot of hassle if things go wrong!
`To do  this, first   put a blank disk in drive 'A:', and then type
`the following :-


`     FORMAT A: /S


`Now, if   you muck  up you  system, slap  this disk  in the drive,
`restart your  computer, and  you will  be given a DOS prompt.  You
`can then go about fixing the problem.

`If the   problem has  come about  because you  have messed up your
`AUTOEXEC.BAT during   editing,  the  easiest  thing  might  be  to
`recover the  back-up file  you made earlier.  To do this, type the
`following :-


`     COPY C:\AUTOEXEC.BAK C:\AUTOEXEC.BAT




~`                          
~`                          Back to Basics
~`                          


`Now you  can safely edit your AUTOEXEC.BAT. To do this I recommend
`you use  the MS-DOS program "MS-DOS Edit".  This is  found only in
`versions of  MS-DOS, 5  or above.   If  you don't have this you'll
`have   to   use  MS-DOS's  Edlin  which  is  far  inferior.    For
`information about Edlin and Edit, consult your DOS manual.

`To use  MS-DOS Edit  to edit your AUTOEXEC.BAT, type the following
`three commands, each with an [ENTER] press after them as before :-


`     C:
`     CD\
`     EDIT AUTOEXEC.BAT


`Don't be  lazy and  leave out  the ".BAT"  at the end of the third
`command, otherwise MS-DOS Edit will open a new file for you called
`just "AUTOEXEC.   " which won't work.




~`                 
~`                 How can I edit my AUTOEXEC.BAT?
~`                 


`Once Edit  has loaded, a simple  (but very effective)  text editor
`will  be   displayed,  listing   the  current   contents  of  your
`AUTOEXEC.BAT.   As with  any word-processor,  you can move through
`the text  with  the  cursor  keys    (or  the  mouse),  and  enter
`information by moving the cursor to the required space and typing.

`Your AUTOEXEC.BAT  may look  something like  this, although  it is
`likely to  have far fewer lines if this is the first time you have
`edited it :-


~`     @ECHO OFF
~`     PROMPT $P$G
~`     PATH C:\;C:\WINDOWS;C:\DOS;C:\MOUSE;
~`     SET TEMP=C:\TEMP
~`     SET DIRCMD=/ON
~`     SET BLASTER=A220 I5 D1 T4
~`     C:\MOUSE\MOUSE.COM
~`     C:\WINDOWS\SMARTDRV.EXE /X 1024 512
~`     C:\DOS\MSCDEX.EXE /D:MSCD000
~`     C:\DOS\DOSKEY
~`     C:\DOS\VSAFE.EXE


`Those lines  starting with the path name of a file  (the last five
`lines)  all load up software which could easily be loaded from the
`DOS prompt.   The first 6 lines, however, are not loading software
`but issuing  commands, although  these lines could also be entered
`at the DOS prompt as with any line in a batch file.




~`                
~`                Writing and Editing AUTOEXEC.BATs
~`                


`AUTOEXEC.BAT files,   as  I have  already said,  are made-up  of a
`series of lines, each of which do their own job.  The rest of this
`document is aimed at helping you understand each line.



~`The "Echo" Command
~`

`This line  is not actually needed to load any software but it is a
`command used  to preserve  sanity!!  Normally when you run a batch
`file, DOS  will list  each of the commands as it loads them.  This
`looks very  messy and  is almost  always a complete waste of time.
`Because of  this, nearly  all batch files will start with the line
`"ECHO OFF"  which stops  your computer  from doing  this  annoying
`habit!!!!    The  line will  look like this, and will obviously be
`the first  line in  the AUTOEXEC.BAT  so it  will affect ALL other
`lines :-


`     ECHO OFF


`Unfortunately, the  effect of  having "ECHO  OFF" does  not affect
`itself, so  when a  batch file  is loaded with this line in, "ECHO
`OFF" will  be displayed  on the  screen.   If this  is not desired
`either, put  a '@'  sign at  the front of the line, and that won't
`happen either.  Now the line will look like this :-


`     @ECHO OFF



~`The "Prompt" Command
~`

`As you  will know,  the "C:\>", "D:\GAMES\FURY>", "E:\UTILS>" etc.
`text which  is your prompt to enter a new command in DOS is called
`a DOS  prompt.  What you might not know is that you can change the
`look of  this prompt.   It  doesn't have  to display  your current
`drive and  directory -  it could  display the  time and date, or a
`specialised message  - it  can even  be several  lines long and in
`colour!!!

`Normally the  line which  tells your  computer  what  your  prompt
`should look like, reads :-


`     PROMPT $P$G


`This tells  your computer  to inform you of your current drive and
`directory, and  put a  '>' symbol  at the  end of  this.   To have
`different prompts is easy...

`If you  want a  specialised message  as the prompt, you simply put
`this message  on the  same line  as the  "PROMPT"  command.    For
`example, if  you wanted  a prompt  that says "What next Bub?", you
`would use the following line in your AUTOEXEC.BAT :-


`     PROMPT What next Bub?


`If you  want other  things such  as the current time and date, you
`must use  special codes  in your prompt line like the $p$g used in
`the default prompt.  Here's a list of the codes you can use :-


`     $Q   -   = (equal sign)
`     $$   -   $ (dollar sign)
`     $T   -   Current time
`     $D   -   Current date
`     $P   -   Current drive and path
`     $V   -   MS-DOS version number
`     $N   -   Current drive
`     $G   -   > (greater-than sign)
`     $L   -   < (less-than sign)
`     $B   -   | (pipe)
`     $_   -   ENTER-LINEFEED
`     $E   -   ASCII escape code (code 27)
`     $H   -   Backspace  (to delete a character that has been
`              written to the prompt command line)


`Example :-


`If you  want the  prompt to have the text 'I'm waiting!', then the
`time, then  on a  new line,  the current  drive and directory, you
`would have your "Prompt" line as follows :-


`     PROMPT I'M WAITING!  $T$_$P$G


`The "I'm  Waiting" part tells it what message to have at the start
`of the  prompt.   The two  spaces simply separate the message from
`the time.   The  "$T" tells  it to  display the current time.  The
`"$_" tells it to go down to the next line.  Then the "$P" tells it
`to display  the current drive and directory, and the "$G" tells it
`to round it all off with a '>' sign!!!

`If you  want your  prompt in  colour, you'll  first need  to  load
`"ANSI.SYS" in your CONFIG.SYS.  To do this add the line :-


`     DEVICE=C:\DOS\ANSI.SYS


`...to your  CONFIG.SYS.   You can  now change  the foreground  and
`background colours  of the  letters in  your prompt  by using ANSI
`escape sequences.   For  information on this type the following at
`the DOS  prompt  (so long as you have DOS v6.x or higher), because
`it is too complicated to explain in this document :-


`     HELP ANSI.SYS



~`The "Path" Command
~`

`This is  a very useful command indeed, which allows you save loads
`of time  by reducing  the need to continuously change directory to
`access different programs.  Basically, if you type in a file name,
`your PC will first check the current directory to see if a file by
`that name  is situated  there, then it checks for the same file in
`all directories  you specify  on the  "Path" line.    The  default
`"Path" line which DOS gives you will check the "C:\" directory and
`the  "C:\DOS\"   directory,   and   windows   will   usually   add
`"C:\WINDOWS\" to  this too.  However, you can add more directories
`to this.

`All you  need to  do is  type the  full path of the directory, and
`make sure  each new  directory you  want checked is separated by a
`semi-colon   (a ';').  For example, here's a path you could use to
`check the directories: C:\DOS, D:\WORD, C:\WINDOWS, D:\GAMES :-


`     PATH C:\DOS;C:\WINDOWS;D:\WORD;D:\GAMES



~`Environments
~`

`There are quite a few environments that can be set within DOS.  It
`is difficult  to explain  what an  'environment' in computer terms
`is, as each one can do a different job.  Instead, I will cover the
`three most popular ones here and you might get the idea.


~Environment 1  -  "Set Temp"

`If you run windows with virtual memory this line is essential.  If
`you do  not have  it, windows  writes it's  temporary files  (.TMP
`files)   to the root directory of your hard disk which clutters up
`the most  important part  of  the  disk  with  messy  and  useless
`files!!!  Instead, though, you can use the "Set Temp" directory to
`tell windows   (and  DOS, I think)  to put their useless temporary
`files elsewhere!!

`Obviously, it's  a good  idea to  put  .TMP  files  in  their  own
`directory so  they don't  clutter up  other software,  and now and
`again, go into this directory and delete the annoying things since
`not only do they get in the way but they can take up a consideable
`amount of disk space after a while.

`To set  the directory  where .TMP files are written to as C:\TEMP,
`you must put the following line in your AUTOEXEC.BAT :-


`     SET TEMP=C:\TEMP


~Environment 2  -  "Set DIRCMD"

`Whenever you type "DIR" it will give a listing of all the files in
`the current  directory.  If you type "DIR" followed by one of many
`commands, you  can change  the form  ths  listing  takes  (eg,  by
`sorting the  files into  alphabetical order,  by putting  all  the
`words in  lower case  etc).   If there  is one  of  these  special
`options which  you always  use when  typing "DIR", you can use the
`"Set DIRCMD"  line to  make it so that this command will always be
`used even  if you  don't type  it alongside  the "DIR"  at the DOS
`prompt.

`Here is  a full list of all the commands you could use on the "Set
`DIRCMD" line :-


`     /P      Pauses after each screenful of information.
`     /W      Uses wide list format
`     /AD     Displays only directories
`     /AR     Displays only read-only files
`     /AH     Displays only hidden files
`     /AS     Displays only system files     
`     /AA     Displays only files ready for archive
`     /ON     Displays files in alphabetical order
`     /OS     Displays files in size order  (smallest first)
`     /OE     Displays files with extensions in alphabetical order
`     /OD     Displays files in age order  (oldest first)
`     /OG     Group all directories at start of directory listing
`     /OC     Displays files by compressive ratio  (smallest first)
`     /S      Displays files in directory and all subdirectories.
`     /B      Uses bare format (no heading information or summary)
`     /L      Uses lowercase.
`     /C      Displays file compression ratio
`     /CH     Uses host allocation unit size.
     

`The line  you use  to set  your directory  command is  as follows.
`Simply replace  the '#' sign with one or more of the commands from
`the table  above   (although, beware  that some  commands will not
`perform if used in conjunction with certain others) :-


`     SET DIRCMD=#


`For example,  if you  wanted all  your directory listings to be in
`lower case,  alphabetical order,  and have the directories grouped
`together at the top, you'd use the following line :-


`     SET DIRCMD=/OG /ON /L


~Environment 3  -  "Set Blaster"

`This environment sets the commands for your soundcard.  Obviously,
`if you don't have a soundcard, you don't need the line.  Also, you
`will only  need the  line for  those games  which don't detect the
`card's specifications  itself.    Those  games  will  require  the
`information in the shape of this line instead.

`The  line   tells  software  your  soundcard's  channel,  its  IRQ
`(Interrupt ReQuest), its DMA (Direct Memory Address) and what type
`of soundcard  it is.   The  line would read as below, where '!' is
`replaced by  the channel,  '@' by the IRQ, '#' by the DMA, and '$'
`by the type :-


`     SET BLASTER=A! I@ D# T$


`For example, my Sound BlasterPro uses the following line, with 220
`as the channel, 5 as the IRQ,  1 as the DMA and 4 as the type :-


`     SET BLASTER=A220 I5 D1 T4



~`Commands
~`

`The rest  of the  lines described in this document are used to run
`actual software rather than set options.

`As a  rule, any  lines aimed  at just  loading software in a batch
`file, simply  give the  full path  of the file needed, followed by
`the file  name.   So, for  example, this  line will  load the file
`"GWSHARE.EXE" from the directory "C:\DOS\GW" :-


`     C:\DOS\GW\GWSHARE.EXE


`From here to the end of this document are five examples of popular
`software which  is often  run using AUTOEXEC.BAT, where it is, how
`to run it, and what it does :-



~Program 1  -  The Mouse Driver

`As you  will probably  know, you  will always need to load a mouse
`driver before  you can  use your mouse.  A mouse driver tells your
`PC how  to translate  the commands  the mouse  sends to  it.  Most
`mouses are  bought with  a driver on disk, but there is usually no
`need to  use this  since there  is a  driver which  comes with DOS
`called "MOUSE.COM".  Although this only has few features, it seems
`to work  with just  about all  mouses and is easy to use.  To load
`this DOS  mouse driver,  simply add  the following  line  to  your
`AUTOEXEC.BAT :-


`     C:\DOS\MOUSE.COM



~Program 2  -  "Smart Drive"

`This is  a cache  program.  Basically, when your computer requests
`some information  from a  disk, "Smart  Drive" will  take a little
`more than  the requested  amount, and  store this  in a  cache  (a
`small portion  of memory).   This  is because  when information is
`requested from  a  disk,  the  next  request  will  often  be  for
`information next to this information on this disk.  Because "Smart
`Drive" has  already requested  a little more, if this is the case,
`your computer  can quickly take this from the cache without having
`to go back to the disk, which saves time and wear on your drives.

`Before loading  "Smart Drive"  you must have loaded "HIMEM.SYS" in
`your CONFIG.SYS   (see issue 39 of Cheet Sheets for information on
`how to do that).

`When you  load up  "Smart Drive"  you can  specify the size of the
`cache during both DOS and Windows sessions.  Obviously, the bigger
`the cache, the larger the amount of extra information that will be
`requested,  so   the  quicker  your  system  should  run  in  most
`circumstances.  The InitCacheSize is the cache size whilst running
`under DOS.   The  WinCacheSize is  the size  of the  cache  whilst
`running under  windows.   When windows  is  loaded  the  cache  is
`reduced to free more memory for windows itself.

`If you  don't specify  the  IntCacheSize  and  WinChacheSize,  the
`following defaults are used :-


`     Extended        InitCacheSize       WinCacheSize
`     Memory          (ICS)               (WCS)
`     ĳĳ
`     Up to 1 MB      All XMS memory      Zero (no caching)
`     Up to 2 MB      1 MB                256K
`     Up to 4 MB      1 MB                512K
`     Up to 6 MB      2 MB                1 MB
`     6 MB or more    2 MB                2 MB


`The following  line should  be used  to load  "Smart Drive"  where
`'ICS' is the InitCacheSize, and 'WCS' is the WinCacheSize :-
     

`     C:\WINDOWS\SMARTDR /X ICS WCS


`(The /X  tells smartdrv to use extended memory  (useful when using
`/AUTO in the EMM386 line of your CONFIG.SYS)).



~Program 3  -  "MSCDEX"

`If you  have a  CD-ROM drive, you will have a CD-ROM driver loaded
`in your  CONFIG.SYS program.   As  well as this, however, you will
`also need  "MSCDEX.EXE" loaded  in your  AUTOEXEC.BAT.   This file
`will work with any CD-ROM drive.  All it does is provide access to
`the CD-ROM drive.

`Both the  "MSCDEX.EXE" line in your AUTOEXEC.BAT file, and the CD-
`ROM driver  line in  your CONFIG.SYS  should have a parameter that
`specifies the  driver  signature  for  your  CD-ROM  drive.    The
`signature specified  in your  CONFIG.SYS must  be the same in your
`AUTOEXEC.BAT.   This signature  is a  parameter which  reads "/D:"
`followed by  a label  up to  8 characters  long.  This is normally
`something along the lines of 'MSCD000'.

`The line  in your  AUTOEXEC.BAT to  load "MSCDEX.EXE"  might  read
`something like this :-


`     C:\DOS\MSCDEX.EXE /D:MSCD000


`If this  is the  case, a  corresponding line  the CONFIG.SYS might
`read as follows  (although this greatly depends on what the driver
`is called, where it is stored, and what options it supports) :-


`     DEVICE=C:\CDROM\CDMIKE.SYS /D:MSCD000



~Program 4  -  "DOSKEY"

`If you  use DOS  a lot  and are  a fairly slow typer, a very handy
`utility is  DOSKEY.   This remembers the last 20 commands you have
`entered at the DOS prompt, which you can then scroll through using
`the cursor up and down arrows.  This allows you to go back and run
`a command  you used minutes ago without having to type the command
`again.   What makes  this even  better is  that it only uses 3K of
`memory!!!!!

`To load DOSKEY, simply add the following line to your AUTOEXEC.BAT
`:-


`     C:\DOS\DOSKEY.EXE



~Program 5  -  "VSAFE"

`As every  computer user should know, the use of a virus checker is
`essential  unless  you  want  to  risk  losing  great  amounts  of
`important data  in a matter of minutes.  What's even better is the
`use of a memory-resident virus checker, which will sit 'silently;'
`in your  memory continuously  checking your  memory and  your hard
`disk for viral activity etc.

`Well, have  you ever  heard of  VSAFE?  This is DOS's attempt at a
`memory-resident virus-checker.   This  file is very small, easy to
`use, and,  as soon  as it  spots a  virus wreaking  havoc on  your
`system, it  stops all  activity and  gives a  great warning alarm.
`You can  then shut  your system  down, and  load a virus killer to
`kill the virus as soon as possible.

`To load  VSAFE is  easy -  simply add  the following  line to your
`AUTOEXEC.BAT :-


`     C:\DOS\VSAFE.EXE



~`            *                   *                   *



`Well, there  you go  folks, there  it is.  Hope this helps  (along
`with our  guide in  issue 39  on writing  your  CONFIG.SYS)    you
`understand the  more complicated parts of the running of a PC, and
`how to optimize performance....



`             
~`              By:  Simon Burrows  -and-  Alex Willmer
`             

