This article was co-authored by wikiHow staff writer, Darlene Antonelli, MA. Darlene Antonelli is a Technology Writer and Editor for wikiHow. Darlene has experience teaching college courses, writing technology-related articles, and working hands-on in the technology field. She earned an MA in Writing from Rowan University in 2012 and wrote her thesis on online communities and the personalities curated in such communities.
This article has been viewed 4,584 times.
Learn more...
Do you want to simplify the work that you would otherwise do with typing out commands? You can do this by creating batch files (also called .bat files) to automate routines, start apps or launch websites, and change settings. This wikiHow article will teach you how to create a batch file on Windows 10.
Steps
-
1Open Notepad. Notepad allows you to create code as a text file and then save it when you're done as a batch file. You can open Notepad by opening the Start menu, typing in Notepad, and clicking the blue Notepad app icon at the top of the menu.
- Notepad is commonly used to convert text files into batch files, but you can write your batch file's text in any word-processing software, like Google Docs.
-
2Type the following code:
@ECHO OFF ECHO Congratulations! Your first batch file was executed successfully. PAUSE
- However, if you write the same code with a line break between "
ECHO
" and "Congratulations!
" the command will not work since the first item in the line is meant to be a command. Keep @ECHO OFF as the first line in your code so you don't see the normal output from the command prompt opening.
- Keep in mind that the command is the first word on each line. This includes "
DEL
" and the other codes listed below.
Advertisement - However, if you write the same code with a line break between "
-
3Click File. It's in the top left corner of the Notepad window.
-
4Click Save as. This is near the middle of the menu.
-
5Name your file with a ".bat" extension. For example, you can name this "test.bat" so you know it's the test document.
-
6Test the document. Double-click the file you just created. If you made it correctly, a command window will open that says "Congratulations! Your first batch file was executed successfully."
- There are many possibilities for creating batch files, if needed, you can search the Internet for more codes. You can, for example, type "Echo" and then type a sentence or two that you want displayed in the Terminal window. Use "DEL" with a file location to delete files or files, like
"del test.bat"
Create more advanced batch files by using different commands:- ECHO - Displays text on the screen
- @ECHO OFF - Hides the text that is normally output
- START - Run a file with its default application
- REM - Inserts a comment line in the program
- MKDIR/RMDIR - Create and remove directories
- DEL - Deletes a file or files
- COPY - Copy a file or files
- XCOPY - Allows you to copy files with extra options
- FOR/IN/DO - This command lets you specify files.
- TITLE- Edit the title of the window.
- There are many possibilities for creating batch files, if needed, you can search the Internet for more codes. You can, for example, type "Echo" and then type a sentence or two that you want displayed in the Terminal window. Use "DEL" with a file location to delete files or files, like
-
7Close your Notepad file. It will be saved as a batch file in your selected location.
- To run it, all you need to do is double-click it.
About This Article
1. Open Notepad.
2. Type the code into your blank document.
3. Click File > Save as.
4. Name your file with a ".bat" extension.
5. Test the document.