The Lost Art of Batch Programming
No matter what other interesting skills you acquire, an ability to write DOS batch files is a skill that you will cherish throughout your life. And should you survive to a hundred and five, batch programs may be the one thing that remains unchanged.
Piping, Pinging, setting the path, echoing.... all the good stuff...
Here's an example of using a batch program to stop an application (CALC.exe in this case) from being run twice on the one machine.
IF EXIST C:\%COMPUTERNAME%.txt GOTO RUNNING
ipconfig > C:\%COMPUTERNAME%.txt
ECHO PROGRAM STARTED...
ECHO PROGRAM FINISHED
IF EXIST C:\%COMPUTERNAME%.txt DEL C:\%COMPUTERNAME%.txt
ECHO FILE IS ALREADY RUNNING
This example used the following:
- ENVIRONMENT VARIABLES (%COMPUTERNAME%)
- REDIRECTION (>)
- LABELS (:)
I'm currently writing a book about how to build your first product. If you want to build your first product, please sign up to be notified when the book is available.