Batch Scripting placeholder cover

Batch Scripting

Bat Files for Beginners to Power Users
by Jack McLarney
May 2024, 472 pp.
Use coupon code PREORDER to get 25% off!

Download Chapter 6: Integer and Float Data Types

Packaged with every Windows computer, Batch is an immensely useful programming language ready to help coders and non-coders alike with routine or repetitive tasks. In addition to easily minimizing daily chores, bat files are great for logon scripts, can automate PC environment configurations, and generally make life easier regardless of what you usually code. 

This book covers all things bat-file-related, from the essentials through the advanced concepts, even object-oriented design. Humorous asides and examples—such as pondering the question “what if Archimedes had Batch,” and sorting the first 8 future captains of the starship Enterprise—make the journey into Batch’s inner workings a truly enjoyable one. 

Topics are organized into three parts of increasing complexity, making it a handy reference tool for whatever Batch task, question, or problem you encounter:

  • Part I provides the basics, where beginners and non-power-users will learn how to write simple to moderate bat files.
  • Part II discusses how to get things done, introducing the crucial for command and how to use it to add even more functionality to the language.
  • Part III covers sophisticated topics at the expert level, like working with recursion and arrays, as well as testing and troubleshooting tips, culminating with object-oriented design.

Regardless of your preferred programming language, anyone with a Windows PC will benefit from learning how to code with Batch—and this is the ultimate user guide.

Author Bio 

Jack McLarney has been coding professionally since 1999 at companies like Protective Life Corporation, Fiserv, and The Hartford Financial Services Group. McLarney teaches part-time at Manchester Community College as an Adjunct Professor of Mathematics and holds an MS in Applied Mathematics from the University of Connecticut.

Table of contents 

Part I: The Essentials
Chapter 1: Batch
Chapter 2: Variables and Values
Chapter 3: Scope and Delayed Expansion
Chapter 4: Conditional Execution
Chapter 5: String and Boolean Data Types
Chapter 6: Integer and Float Data Types
Chapter 7: Working with Files
Chapter 8: Executing Compiled Programs
Chapter 9: Labels and Nonsequential Execution
Chapter 10: Calling Routines and Bats
Chapter 11: Parameters and Arguments
Chapter 12: Outputs, Redirection, and Piping
Chapter 13: Working with Directories
Chapter 14: Escaping
Chapter 15: Interactive Batch
Chapter 16: Code Blocks
Part II: The for Command
Chapter 17: Fundamentals of the for Command
Chapter 18: Directories, Recursion, and Iterative Loops
Chapter 19: Reading Files and Other Inputs
Chapter 20: Advanced for Techniques
Part III: Advanced Topics
Chapter 21: Pseudo-Environment Variables
Chapter 22: Writing Reports
Chapter 23: Recursion
Chapter 24: Text String Searches
Chapter 25: Bat Files Building Bat Files
Chapter 26: Automatic Restarts and Multithreading
Chapter 27: And/Or Operators
Chapter 28: Compact Conditional Execution
Chapter 29: Arrays and Hash Tables
Chapter 30: Odds and Ends
Chapter 31: Troubleshooting Tips and Testing Techniques
Chapter 32: Object-Oriented Design
Chapter 33: Stacks, Queues, and Real-World Objects
Appendix A: Fully Functional Batch Improv
Appendix B: Array and Hash Table Objects

The chapters in red are included in this Early Access PDF.


"Playfully written and technically robust, Jack’s book is fantastic. It is a painless introduction to bat files for beginners and an invaluable reference for experts. Careful scaffolding in the early chapters eases learner anxiety and cognitive overload while providing an immediate payout of practical applications and a robust basis to move forward. Later chapters provide structure for advanced topics, templates to build on, and a thorough examination of bat files, providing amazing functionality and flexibility I did not know was possible."
—Dr. Nicole Engelke, Professor and Director of Quantitative Reasoning, University of Nebraska at Omaha

"If you have to work with Windows, you have to read this book."
—Niel Infante, Senior Engineer, Ginkgo Bioworks

"Having worked professionally in IT since prior to the internet having pictures, I thought I knew bat files. Within the first 30 minutes, I learned things that Batch could do that I never had a clue about. It was a dazzling, factual read mixed with full syntax detail and humor along the way. Highly recommended for anyone as a fun trip down memory lane or an excellent reference in those times of need!"
—Dave Mullen, Senior IT Manager, Windows Administrator, and Cybersecurity Engineer