Presentation on theme: "A batch file is a file that contains a number of DOS commands, each of which could be run individually from the command prompt. By putting them into a."— Presentation transcript:
A batch file is a file that contains a number of DOS commands, each of which could be run individually from the command prompt. By putting them into a batch file, they can be run as a group by simply running the batch file. Note that the commands execute in the order they appear in the batch file, and that anything that causes a command to halt will also halt the batch file.
You create a batch file by using an ASCII text editor, such as DOS EDIT, or Windows Notepad. When you have created the batch file, you save it with a file name, and give it the extension *.bat. Note that you must not use a name that is the same as any DOS commands or any other program or utility you are likely to run. If you use a DOS command name, trying to run your batch file will not work because the DOS command will execute first. Contd..
If your name matches some other program or utility, you may never be able to run that program again because your batch file will run before the program runs. So pick something that is not likely to match any command name or program file name.
.bat: The first extension used by Microsoft for batch files. This extension runs with MS-DOS and all versions of Windows, under COMMAND.COM or cmd.exe, despite the different ways the two command interpreters execute batch files..cmd: The extension used by operating systems in the Windows NT family and sent to cmd.exe for interpretation. It does not work on computers relying on COMMAND.COM so prevents cmd.exe scripts from being executed in the wrong Windows environment. It is also used by IBM's OS/2 for batch files. Contd..
btm: The extension used by 4DOS and 4NT. The scripts run on 4DOS and 4NT are faster, especially with longer ones, as the script is loaded entirely ready for execution, rather than line-by-line.
A simple program that displays a hello world program and then waits for the user to press a key before ending. @ECHO off ECHO Hello World! PAUSE @ECHO on To execute the file it must be saved with a.bat or.cmd extension in plain text format (with a program like Notepad). Result When executed (either from Windows Explorer or Command Prompt) this is displayed: Hello World! Press any key to continue...
Wildcards: Wildcards are characters that can be used to stand-in for unknown characters in file names. In card games, a wildcard is a card that can match up with any other cards. In DOS, wildcard characters can match up with any character that is allowable in a file name. Wild cards are symbols that let you reference groups of related files.
There are two wildcards in DOS: * = matches up with any combination of allowable characters ? = matches up with any single allowable character Types of wild cards
Of course, since these two characters are used for wildcards, they are not allowable in filenames themselves. A filename like myfile?.txt would not be allowed. If you tried to create a file with this name you wouldget an error message “Bad file name.” But wildcards are very useful in any DOS command which uses a filename as an argument.
The asterisk character, *, can stand in for any number of characters. Some examples of this command: c:\>del *.doc This command would delete every file with the doc extension from the root directory of C: C:\>copy ab*.txt a: This command would copy every file that began with ab, and had an extension of txt, to the floppy drive A:. So files like abstract.txt, abalone.txt, and abba.txt would all be copied.
The question mark wildcard, ?, stands in for any single character. Some examples of this command: C:\>del ?.doc This command would only delete files that had a single character filename and a doc extension from the root directory. So a file like a.doc or 1.doc is history, but a file like io.doc is perfectly safe, since it has two characters.
You can combine these wildcards in any command as well. C:\temp\>del *ab?.do? This command would be very selective. It would look in the temp directory for files that had anywhere from 1 to 5 beginning characters, followed by ab followed by one character, and which had an extension of do followed by any one character. It would then delete any such files as matched. Examples of matching files would be itab3.dox, mearabt.doq, and 123abc.doc. But the file allabon.doc would not be deleted because it does not match. It has two characters following the letters ab in the filename, and the command specified one character in that position.
This is an External command. Syntax: FDISK FDISK [/status] Purpose: Prepares a fixed disk to accept DOS files for storage. FDISK provides a set of options related to the preparation of a fixed disk. NOTE: This command is implemented in different ways by different manufacturers. Some may replace it with a command of a different name that carries out somewhat different functions.
A menu will usually be displayed offering these FDISK functions: 1. Create DOS partitions on the fixed disk. Using this option, you can create more than one logical drive on one physical fixed disk. 2. Change an existing partition on the fixed disk. 3. Delete an existing partition on the fixed disk. 4. Display current partition information.
1. Basically FDISK creates partitions (kind of like rooms), on your hard drive. 2. You can have one large partition or divide it into multiple partitions, each eventually being assigned their own drive letter. 3. There are several different ways you may need to run FDISK and hopefully the following instructions covers most of them. Contd..
4. If you need to create a Windows98 boot disk with the necessary files, you can download a Win98 floppy with many extras that are not normally included. 5. Boot with the Win98 boot disk 6. Run FDISK 7. The following instructions all assume that FDISK is running 8. Select Y for large hard disk support. This is what allows for FAT32 partitions