| |
Batch programming is more useful than some people believe. Batch programming is repeatedly used in industry to make recurrent tasks easier and more efficient. Often these tasks are imperative. Such as the many batch files that are in the system32 directory of the Windows operating systems. To view them enter C:\windows\system32 in your Windows Explorer address bar.
Another example that you have is the autoexec.bat file. This file is appropriately named after AUTOmatic EXECution. Commands that are to be executed when DOS starts are placed in this special file particularly on systems that utilize the PROMPT and PATH commands. When pure DOS was the prevalent operating system this was important, however, on our newer Windows guided machines, this is really not of concern. In fact it not recommended that, until you are well versed, and even then, you edit this file or change it in any way on the newer Windows machines. Batch scripts can also be turned into an executable.
You will save your batch files with a .bat file extension. Some of the file naming conventions (requirements) for batch files include not being recommended to use any internal DOS commands for file names (ECHO.bat, ERASE.bat, PAUSE.bat, etc) and SPACES, and it is NOT OKAY to use the following special characters in a filename:
Backslash - \ Slash - / Colon - : Question mark- ? Asterisk - * Quotes - " Less than sign - < Greater than sign - > Pipe - | The period can be used as the separator between the file name and the file extension. The colon is specifically used after a letter to identify a particular disk drive. The asterisk and question mark are special wild card characters. Be careful when using these two characters in your script as they can do some very unpredictable things. The greater than sign, the less than sign and the pipe are special DOS commands to be discussed later in this article. They are also illegal file names. When naming a DOS file you have even more restrictions.
It should also be noted that good recommended practice for batch file names is to not save them as the same name as another file with a different extension. If you already have a file named email.exe try not to save a batch file as email.bat. The format for batch files is a series of DOS commands on separate lines. Example:
First Command Second Command Third Command Fourth Command And so on... |
|
|
|
|
|
|
|
|
 |
Four types of commands are acceptable for a batch file. These are:
internal commands .exe program names .com program names .bat file names As with any DOS procedure you can stop a batch program from executing by pressing Ctrl+C or Ctrl+Break. DOS will ask if you wish to Terminate batch job (Y/N)?. Type N to skip the command you broke out of and proceed to the next command in the batch file. Press Y to abort execution of the batch file and return to the command prompt. Pressing ^Break will produce the same results as ^C.
The last command that we will go over in this section is the VER command. VER stands for VERsion. Enter this into the command prompt and you will be presented with the current version of your DOS program.
The VER command displays the operating system version number.
| |
|
| |
|