How to Make an Easy Password Protected Batch File

296

4

Posted

Introduction: How to Make an Easy Password Protected Batch File

This is a VERY simple passowrd protected batch, lets say i had a batch file that would open a new text file (my_diary.txt) but didnt want people to get to it easly, i would want a password. this is an easy way to do it, you would only really need to know how to use variables...

this is the batch file code to open my txt document:

@echo off

echo %variable% > my_diary.txt

Now i want to place a password on the file, using the variable "variable".

to do so we need to tell the computer to ask for a password, and only open the file if the user types in that word, this is how you can do it (i put in the code assuming you know what the code means)

@echo off

:start

echo Paswword:

set /p variable=

if %variable%==password goto open

if NOT %variable%== password goto fail

:open

echo %variable% > my_diary.txt

:fail

echo Wrong password!!

pause

goto start

the password is "password" but that can always be changed, this will keep asking for the password untill you get it right.

Share

    Recommendations

    • Microcontroller Contest

      Microcontroller Contest
    • Spotless Contest

      Spotless Contest
    • Science of Cooking

      Science of Cooking
    user

    We have a be nice policy.
    Please be positive and constructive.

    Tips

    Questions

    Comments