How to Add a Password to a .Bat File
Open Notepad., Begin your code with @ echo off., Add the finishing touches to end your script.
Step-by-Step Guide
-
Step 1: Open Notepad.
You can open the Notepad application by going to Start, then All Programs, and then Accessories.
In Accessories you’ll find Notepad.
Windows users can just type "notepad"
without quotes, into the start menu and hit enter.
The application will open. , This is the line that you will use to start your script.
Scripting is writing the code that causes the program to run correctly.
This line allows you to start writing text.
After you write that, you will copy the code below. :
A echo enter password to activate program. set/p "pass=>" if NOT %pass%== passwordhere goto :
FAIL , At the end of your program, you need to add the following lines: :
FAIL echo Invalid password.
If you want to write additional text you can.
If you want to have time between the first line of text and the second line of text add a line that says 'ping localhost (number)'.
This designates the amount of time between each line of text.
Put it between the second and third line.
If you want your program to run slowly and give people time to use each line of text, make the ping localhost time longer.
The pause in between each line of text that shows up from the code would be the ping localhost time.
If you want the program to say 'Hello' and then say 'how are you' five seconds later, you would write ping localhost 5 goto :end :end -
Step 2: Begin your code with @ echo off.
-
Step 3: Add the finishing touches to end your script.
Detailed Guide
You can open the Notepad application by going to Start, then All Programs, and then Accessories.
In Accessories you’ll find Notepad.
Windows users can just type "notepad"
without quotes, into the start menu and hit enter.
The application will open. , This is the line that you will use to start your script.
Scripting is writing the code that causes the program to run correctly.
This line allows you to start writing text.
After you write that, you will copy the code below. :
A echo enter password to activate program. set/p "pass=>" if NOT %pass%== passwordhere goto :
FAIL , At the end of your program, you need to add the following lines: :
FAIL echo Invalid password.
If you want to write additional text you can.
If you want to have time between the first line of text and the second line of text add a line that says 'ping localhost (number)'.
This designates the amount of time between each line of text.
Put it between the second and third line.
If you want your program to run slowly and give people time to use each line of text, make the ping localhost time longer.
The pause in between each line of text that shows up from the code would be the ping localhost time.
If you want the program to say 'Hello' and then say 'how are you' five seconds later, you would write ping localhost 5 goto :end :end
About the Author
Tyler Moore
Brings years of experience writing about home improvement and related subjects.
Rate This Guide
How helpful was this guide? Click to rate: