Commit aafb2ee
committed
docs(CMD): explain what a .cmd file is with examples
What
- Documented `.cmd` files as Windows command scripts similar to `.bat`.
- Key features:
- Plain text files with `.cmd` extension.
- Executed by Windows Command Prompt (cmd.exe).
- Run commands sequentially, automating common tasks.
- Introduced with Windows NT; more modern alternative to legacy `.bat` files.
- Included examples:
1. Hello World:
```
@echo off
echo Hello, World from CMD!
pause
```
2. Open IntelliJ IDEA with a Java 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 a foundation for understanding automation on Windows systems.
- Shows how `.cmd` scripts simplify repetitive tasks like launching programs or running sequences of commands.
- Distinguishes `.cmd` from older `.bat` while showing near-identical syntax.
How
- `@echo off`: prevents commands from being displayed while executing.
- `echo`: prints messages to console.
- `pause`: waits for user input before closing the window.
- `start ""`: launches a program in a new Command Prompt window.
- Paths provided after `start` point to executable and optional file arguments.
Logic
- Inputs: sequence of command-line instructions inside `.cmd`.
- Outputs: automated execution of those commands in Windows Command Prompt.
- Flow:
1. Save commands into `.cmd` file.
2. Double-click or run file in CMD.
3. CMD executes instructions line by line.
- Edge cases:
- Quoting required for paths with spaces.
- Missing quotes or wrong paths lead to "file not found" errors.
- Complexity / performance: trivial; execution speed depends on underlying commands.
- Concurrency / thread-safety: multiple `.cmd` files can run in separate CMD instances.
Real-life applications
- Automating software builds or environment setup.
- Launching development tools with specific project files.
- Creating shortcuts for repetitive administrative tasks.
- Batch file replacements in modern Windows scripting workflows.
Notes
- `.cmd` and `.bat` are nearly interchangeable; `.cmd` was introduced for NT-based Windows (NT/2000/XP and later).
- For advanced scripting, Windows PowerShell (`.ps1`) offers richer features, but `.cmd` remains widely used for legacy support and simple automation.
Signed-off-by: https://github.com/Someshdiwan <[email protected]>1 parent 7656a10 commit aafb2ee
1 file changed
+24
-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 | + | |
0 commit comments