Advanced¶
You maintain batch scripts in production — build steps, installers, scheduled jobs. This level is about doing that well: recursion, the registry, interop with wmic and PowerShell, real text processing, performance, hybrid scripts, packaging, and debugging the cryptic failures.
Lessons¶
| # | Lesson | You'll learn |
|---|---|---|
| 1 | Recursion & advanced for |
recursive subroutines, for /R, walking trees, guarding depth |
| 2 | Robust argument parsing | --flags, /opt:value, optional/positional args, quoting |
| 3 | Working with the registry | reg query/add/delete, parsing reg output with for /F |
| 4 | WMIC, where & calling PowerShell |
wmic (and its deprecation), where, one-line PowerShell escapes |
| 5 | Text processing with findstr |
findstr regex, filtering, counting, its many quirks |
| 6 | Performance & pitfalls | pipe subshells, for overhead, when batch is the wrong tool |
| 7 | Hybrid scripts | batch + PowerShell and batch + JScript in one file |
| 8 | Packaging & distribution | self-contained scripts, %~f0, config files, signing note |
| 9 | Debugging techniques | echo tracing, cmd /k, reading the real error |
| 10 | Capstone: deployment automation | a production-grade multi-step deploy script |
When you're done¶
You know batch as well as it is worth knowing. The most valuable advanced skill is judgment: Lesson 6 is about when to stop writing batch and reach for PowerShell or a real language.