Commit 110b669
committed
docs(Batch): explain what a .bat file is with examples
What
- Documented `.bat` (batch) files as Windows scripts for automating tasks in Command Prompt.
- Key features:
- Plain text files with `.bat` extension.
- Run sequential commands in CMD automatically.
- Automate opening programs, running jobs, or managing files.
- Executable by double-click or from command line.
- Included examples:
1. Hello World:
```
@echo off
echo Hello, World!
pause
```
2. Opening Notepad:
```
@echo off
start notepad.exe
```
3. Opening IntelliJ IDEA with project file:
```
@echo off
start "" "C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2023.3\bin\idea64.exe" "D:\Projects\JavaTutorials\src\Main.java"
```
Why
- Provides clear introduction for beginners and developers to automate tasks in Windows.
- Highlights both simple scripting (echo, pause) and real-world usage (launching applications with arguments).
- Explains relation of `.bat` to Windows automation workflows.
How
- Explained role of:
- `@echo off` → hides commands from being echoed in terminal.
- `echo` → prints text to console.
- `pause` → waits for key press before closing window.
- `start` → opens a new process or window.
- Detailed step-by-step guide to create and run `.bat`:
1. Write script in text editor.
2. Save with `.bat` extension.
3. Double-click file or run in CMD.
Logic
- Inputs: commands listed line by line in `.bat` file.
- Outputs: execution of those commands by Windows CMD.
- Flow:
- CMD interpreter reads commands from file and executes them in order.
- Edge cases:
- Quoting required for paths with spaces.
- Without `""` after `start`, file paths with spaces can fail.
- Complexity / performance: trivial; limited by underlying commands.
- Concurrency / thread-safety: multiple `.bat` files can run independently in different CMD sessions.
Real-life applications
- Launching development tools (IntelliJ, Eclipse, VS Code).
- Running scripts or build jobs in sequence.
- Automating file operations (copy, move, delete).
- Scheduling system tasks via Windows Task Scheduler.
- Useful in deployment and testing pipelines.
Notes
- `.bat` files are older but still widely supported on all modern Windows versions.
- `.cmd` files are nearly identical but introduced with Windows NT; both work with CMD.
- For advanced automation, PowerShell scripts (`.ps1`) provide richer features, but `.bat` remains simple and effective.
Signed-off-by: https://github.com/Someshdiwan <[email protected]>1 parent aafb2ee commit 110b669
1 file changed
+74
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
0 commit comments