Creating a batch file
MS-DOS users
Microsoft Windows and other users
MS-DOS users
To create a basic batch file in MS-DOS, follow the below steps that give you an example of how to create a basic batch file.
If you wish to add more lines to this batch file you would simply type "edit test.bat" to edit the file again.
pause
dir c:\windows
dir c:\windows\system
Additional information about the MS-DOS edit command can be found on our edit command page. Some versions of MS-DOS and bootable diskettes may not have the edit command; if this is the case, you would either need to obtain the edit.com file to access this file or use the copy con command.
Microsoft Windows and other users
A Windows user can still use the above MS-DOS steps if they wish to create a batch file. If, however, you're more comfortable using Microsoft Windows or your operating system, you can use any text editor, such as Notepad or Wordpad, to create your batch files, as long as the file extension ends with .bat. In the below example we use the Windows notepad to create a batch file.
@echo off
echo Hello this is a test batch file
pause
dir c:\windows
I've been (no joke) a professional Batch File Programmer for about 5 years(before I joined the Navy). If anyone needs help, just ask. :)
Batch files need to end in the file name .bat. A super simple way to do it in dos would be to type at the C:\> type: copy con: filename.bat (this will create the file) then type the echo command "echo" is used to put text on the screen. Then, end with a control +z which will create a ^Z and it will say "one file copied" this will result in a simple batch file that says whatever is put after echo. To launch the file, type filename.bat ... So, to recap it should look similar to this:
copy con: filename.bat
echo Hi World
^Z (control + Z)
279 views
Usually answered in minutes!
×