How to Add a Password to a .Bat File

Method 1 of 2:

Writing Your Code

  1. How to Add a Password to a .Bat File Picture 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. [1]
  2. How to Add a Password to a .Bat File Picture 2
    Begin your code with @ echo off. 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. [2] After you write that, you will copy the code below.
      1. :A
  3. echo enter password to activate program.
  4. set/p "pass=>"
    1. if NOT %pass%== passwordhere goto :FAIL
  5. How to Add a Password to a .Bat File Picture 3
    Add the finishing touches to end your script. At the end of your program, you need to add the following lines:
      1. :FAIL
      1. 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
      2. goto :end
    1. :end
Method 2 of 2:

Finishing Up

  1. How to Add a Password to a .Bat File Picture 4
    Change "passwordhere" to the password of your choice. You can choose whatever password you want. It can be as long as you want too. Just remember to keep the quotation marks. [3]
  2. How to Add a Password to a .Bat File Picture 5
    Save the file with an ending of .bat. The default will be .txt, so you'll have to change this. If you've already saved the file just go to file, then save as, and then change the extension to .bat. You might need to check the box saying 'show extension' if you don't see .txt.
  3. How to Add a Password to a .Bat File Picture 6
    Navigate to Performance and Maintenance. You can reach this tab from the Control Panel of your computer. Now go to Scheduled Tasks and navigate to the file that you just created. You can set it to run whenever you want it to – when someone tries to log on, when they try to open a certain file or folder, or any other prompt. [4]
3.6 ★ | 22 Vote

May be interested

  • How to remove PDF file password on MacHow to remove PDF file password on Mac
    sometimes you also need to remove the password that protects your pdf file so that everyone can access and view it without limits.
  • How to Remove the Password from a Zip File Without Knowing the PasswordHow to Remove the Password from a Zip File Without Knowing the Password
    this wikihow teaches you how to gain access to a zip folder which has an unknown password. the only way to do this is by downloading a program which can crack the password for you, though the process of cracking the password can take days...
  • How to set a password for File, FolderHow to set a password for File, Folder
    how to set a password for file, folder. if you want to improve security to prevent unauthorized access from anyone, even hackers, i recommend that you set passwords for important files and folders.
  • Set a pass (password) for any file using WinRARSet a pass (password) for any file using WinRAR
    set a pass (password) for any file using winrar. privacy of personal data is a very necessary task for each of us. to do that, the first thing you need to do is set a password to prevent unintended access. today thuthuatphanmem.v
  • How to Copy Secure PDF Files on Windows or Mac ComputersHow to Copy Secure PDF Files on Windows or Mac Computers
    this is an article showing how to copy text from a pdf file with editing functions locked on a windows or mac computer. when a pdf file has a password set to lock the editing function, you cannot copy the content in most pdf file viewing programs. if you don't know the password, you can save the file as an unsecured pdf using google chrome or unlock it using the smallpdf site. if you know the password, unlock the file using adobe acrobat pro. these methods only work if you can still view and print the pdf without a password. if the pdf file is encrypted and has a password lock that prevents you from viewing the file the first time you open it, it means you can't bypass the security settings.if you need to create, merge, or convert pdf files, try tipsmake's pdf toolkit - it's a free and easy-to-use tool that helps you process documents more efficiently.
  • Can a ZIP archive have 2 passwords? Why is that?Can a ZIP archive have 2 passwords? Why is that?
    did you know that a zip file can have up to 2 correct passwords and both produce the same result when the zip file is unzipped?
  • Set password protection file not open and save content editSet password protection file not open and save content edit
    ms word: you want to protect your documents that no one can read; or just read without editing, quantrimang.com will guide you how to set a password to protect the file as follows:
  • How to Add a Password to a RAR FileHow to Add a Password to a RAR File
    a rar file is a compressed archive that can contain hundreds of other files. rar is popular because of how much the file size can be compressed, as well as the powerful encryption that is built-in. with just a few clicks, you can encrypt...
  • 5 steps to remove PDF password online5 steps to remove PDF password online
    in the previous article, we showed you how to set a password for a pdf file online. today, we will continue to share how to remove that password online quickly and simply. please consult.
  • 5 online tools to remove pdf file limits5 online tools to remove pdf file limits
    to protect pdf file content is always safe, do not allow others to change or edit, usually the computer user or set an access password or set certain limits for the file. doing this may bring you some troubles when even you yourself cannot remember the characters used as passwords, the best way to be able to manipulate pdf files in this case is to remove them. those limits.