How to create batch file Level of difficulty:
Batch files or .bat files (as they are seen) are basically a cluster of files that can be sequentially executed to perform a list of predetermined functions and commands. These files allow Windows and MS-DOS users to locate and assign frequently used commands, or similar commands in a repetition sequence and run it through a batch file. Batch files could perform a number of actions like executing common commands, deleting a file sequence, moving files from one location to another and so on. The best part of using batch files is that its codes are fairly simple and does not require specific programming knowledge on the part of the user. A regular batch fie could be written and assigned functions through MS-DOS commands. Materials Needed:
- Specialized software
Batch files could be Windows or Mac shortcuts on the desktop that actually creates a link with the main program executable. Batch files could also be used to run multiple commands and execute numerous functions through the command line. As explained earlier, creating a batch file does not even require Windows, as one could easily assign a batch file using MS-DOS. To create a basic level batch file, one should first open any MS-DOS command or access the primary MS-DOS window. At the DOS prompt, the user should type [:edit test. bat] and enter this command. The output display would be a blue screen. Within that blue screen, one should type the following command Pause dir c:\windows dir c:\windows\system
Once the user has typed in these lines, the ‘File’ option should be clicked followed by ‘Exit’. The command should be saved by clicking the ‘Save’ or ‘Yes’ option at the confirmation window. This should bring the user back to the MS-DOS prompt. Once there, the user should type in :test, press enter. This should initiate the execution of the test.bat file and begin running the file. On pressing a key, the batch file would be executed a line at one time (line-by-line), listing these files in the windows system directories. One could easily edit or increase/ decrease/ reassign this batch file to perform other commands by simply typing ‘edit test.bat’ to edit this batch file. In case of non-availability of edit command in some MS-DOS versions, the file could be accesses using the copy con command.
Windows users could use MS-DOS prompt to create batch files, or use any text editor program like Notepad or WordPad to create these batch files. The only thing to remember is to keep the extension name for these files as .bat