Add A Password To A .Bat File

Add A Password To A .Bat File
Add A Password To A .Bat File

If you want to add password protection to a windows batch script, follow the simple steps below

Open notepad by going to Start> All Programs> Accessories> Notepad. Vista and 7 users can just type “notepad, without quotes, into the start menu and hit enter

Copy the following code:

  • :A
  • echo enter password to activate programme
  • set/p “pass=>”
  • if NOT%pass%== passwordhere goto:FAIL

At the end of your programme, you need to add:

  • :FAIL
  • echo Invalid password
  • goto:end
  • :end

Note

Change “passwordhere” to the password of your choice.

This is a very basic password code. Anyone with knowledge of .bat files will still be able to access it.

Raja Rajan

Raja is obsessed with technology and Cricket for as long as he can remember. Nowadays he work as a freelance developer and writer for PrimeInspiration.com

Help Us Grow

If you like this post, please share it with your friends.

You are free to copy and redistribute this article in any medium or format, as long as you keep the links in the article or provide a link back to this page.

Subscribe to our mailing list

You may also like...