home Guide The Principles of Batch Process Program Development: Multi-Layered Program Security

The Principles of Batch Process Program Development: Multi-Layered Program Security

It’s important for your batch process programs (and any program that you write for that matter) to demonstrate ideals of the utmost security. These files (assuming that you’ve locked down the permissions on your computer) are the keys to opening up sensitive system resources and locating and exploiting susceptible databases; ultimately leaving a programmer exposed. With batch process programming it is possible to create a much more secure data table by employing multi-tiered or multi-layered measures of security. This means that where once there was simple password employed to protect information, now a series of autonomous “firewalls” puts a user under intense (and often times invisible) scrutiny, separating them from sensitive information about your program. Let’s go over some of the ways in which we can make this happen.


There’s not much to be said about it; passwords are and will always be boss in the world of computer security. Setting passwords in batch is easy, but is it enough? Will you trust your file system with a wall no wider than a few letters? Not me! But lets keep in mind that they are a good way to initialize a user, and let that user know that they are being watched.

Setting a password

We’ve gone over setting passwords in several past lessons, however, we’ll go over it very briefly here since it is so ultimately important. To set a simple password, simply gather the user information with the SET /P command, and match the terms with an IF statement, like so:

SET /P password= What is the password?


In this example, the IF statement is matching conditions to the variable password, if the variable does not equal the word “Cool”, then the subsequent ELSE command will take effect. As I’ve said earlier, there are many more advanced ways to employee passwords (so get reading), but this will give you a basic concept.


Registering users is by far my favorite way to go about program security. Think about it; you now know how and when a user has used the program and can enable system logs to store information about the users session, or prohibit a user from accessing particular features. Its security features like these that help build customizable, individualized programs. Make sure to include a section in your script where a user can register their information. You can then have it sent to you, or stored in a log file somewhere to be used later by the shell. For example:


SET /P registered= Have you registered with this program before?

IF %registered%==YES (GOTO START) ELSE ((ECHO “Well, let’s get you registered”)  amp; (GOTO REGISTER ))


SET /P name=What is your name?

SET /P pAssword=What is your desired password?

IF EXIST %name%.txt (ECHO It actually looks like you’ve already registered) ELSE ((ECHO @ECHO OFF  gt; %name%.bat) amp; (ECHO set NAME=%name% gt; gt; %name%.bat) amp; (ECHO SET PASSWORD=%password%  gt; gt; %name%.bat))


This program registers a user by creating another batch file (log file) with their information. Note that the name and password were saved as the variables NAME and PASSWORD within the file. This way we can compare these variables with IF statements in the future instead of writing one universal password for all users. Using this technique, we can individualize users with statements like:

SET /P passwordcompare= What is your password?

IF passwordcompare==password GOTO START

instead of having to universalize information (making a program much less secure).

The Self-Terminating Program 

The beginning of the program can be done through a click at the https://www.wavemaker.com/rapid-application-development-model/ site. The platform provided will match with the needs and specifications of the person. The charges will be less for the person for the model. 

Finally, let’s say that we’ve written a program that contains REALLY important information (ie. the girl/guy that you like, your favorite breakfast cereal ,etc. ) and have to MAKE SURE that there is no way that a little brother, friend, mortal enemy or God himself can get in without the password. If this is the case, then a self-terminating program is the answer. What this program will be designed to do; is accept a certain amount of incorrect passwords, and upon reaching a certain number of attempts, delete itself. That’s right! So, first things first, make sure that you save an extra copy of this file somewhere without the function enabled to ensure that you don’t delete your important information accidentally. Then, install the following code within a security or password module in the preface of your program:



SET /P password= Password, please:



ECHO Error, invalid password.

SET /P password= Password, please:



ECHO Error, invalid password. This is your last attempt.

SET /P password= Password, please:



ECHO Your privilege to this security console has been disabled. Good bye.


DEL password.bat

The user will be guided linearly through each module, being asked gradually for a correct password. However, upon reaching the :SORRY module, the message, “Your privilege to this security console has been disabled. Good bye.’ would have been displayed, a log file would have documented the termination time and date, and the program would have self-terminated. In this a way, a user is truly limited in what functions they can perform without a password, in much the same way that a user will be locked out of bank software if they can’t meet the security parameters.

With the culminative efforts of each of these security measures ( and improvised measures by you), it will literally be impossible for unauthorized sources to access your software. Keep in mind that building your program as an executable file will add to the security layer (read lesson), allowing no one to edit your program either. It’s important that you understand that these measures of security, even for the weakest of programs, are inevitably important. Protect your files, your work and your information! And as always have fun, experiment, and happy programming.

Thanks for reading, and don’t forget to continue on to learn more about command-line and batch process programming by referring to The Principles of Batch Process Program Development series.


David Robson

David Robson is the founder of Complus Alliance. He has been writing about different topics for almost 10 years. He’s main focus is delivering quality insights to a wide array of audience.