Opening Files in a Text Editor
Learn to open and edit files with Notepad directly from the command line.
Start Interactive LessonOpening Files in a Text Editor
Before you can write or modify a batch script, you need to know how to open a file in a text editor from the command line. On Windows, the built-in editor is Notepad — and you can launch it for any file directly from CMD.
Step 1: Open a Text File
Type notepad readme.txt in the terminal. Notepad opens the file so you can read and edit it.
Tip: If the file does not exist yet, Notepad will ask if you want to create it. Click Yes and start typing!
Step 2: Open a Batch File for Editing
The real power comes when you open .bat files to write commands:
Why Notepad? Notepad saves files as plain text — exactly the format CMD needs to execute
.batscripts. Never use Word or rich-text editors for batch files.
Step 3: Save and Close
Once you finish editing in Notepad:
- Press Ctrl+S to save
- Press Alt+F4 (or File → Exit) to close
- Return to CMD and run your script:
script.bat
REM After saving your edits, run the file:
script.bat
Knowledge Check
1 / 3Which command opens a file in Notepad from CMD?