|
Silly Software Company
-=oOo=- A poor man's way of doing things is still a way to get things done |
Creating a Batch file
Creating a bat file is done in two easy steps
Creating the file
For this, you'll need a text editor. It can also be done with a word processor.
A text editor is an application to create text. You start the editor, such as Windows Notepad, or type
edit
at the DOS prompt.
In this file you write or copy/paste the commands you want executed - see a sample bat file
Then you save the file:
Typically, a text editor will save the file with extension .txt,
You don't want this, so you'll change the file extension, using
the change file name option, or by choosing from the menu File
| Save As | File type : All files (*.*) and creating a filename
that ends with .bat
e.g. batman.bat
This file is executable, which means that by typing batman (the .bat extension is not necessary), all commands in the batman.bat file will be executed.
Other ways to run an executable file such as batman.bat:
(double) click it in Windows Explorer
from Start, choose Run & type batman, ...
Autoexec
a typical bat file is autoexec.bat, which can be found on your 'system root directory', usually indicated with c:\
autoexec.bat is a bat file that is automatically executed every time you start your computer. Before Windows 95, it included commands and settings to adapt the computer to the user's needs.
When working in DOS, it may be necessary to add a line to this
file.
Unlike in Windows, where you see your files on the screen and
click them to run them, DOS needs to be told where a file is,
or where it can be found.
When typing a command (e.g. batman.bat), DOS will not know where this file is, and thus will not execute it.
However, DOS will always look on the 'path' to see if it can find the command or executable (.exe, .bat) file.
Lets assume you save your batch files in a directory 'batch' on your hard drive C. (i.e. c:\batch").
Then you can let DOS know to look for bat files in this directory by adding this line to your Autoexec bat :
set path=c:\batch;%pat%
After rebooting (to activate this new configuration), DOS will, whenever you want to start an executable file, look in the directories (or 'File Folders') mentioned in the path statement to see if the file you want to run, is there.
%path% means : include previous path settings. In Windows 95/98 this path can be defined in the Windows Registry - so it can be wise to include it : it includes the \windows\command directory which is where a lot of DOS commands can be found - you'll need them.
You can check the path by typing path at the command prompt (c:\>)
you'll be shown all directories that are included in the path.