Password in a batch file

March 20, 2009 at 08:01:41
Specs: Windows Vista
Hi.
I was wondering if it is possible to make someone
type in a username and/or password when they enter
a bat file. So if you want to use the bat file you need
the password. Is this possible to do with variables or
something? Please answer =)
Thanks.

See More: Password in a batch file

Report •


#1
March 20, 2009 at 10:25:24
echo off & cls

set password1=123
:begin
set /p username=Username...
echo Hello %username%, please type in password now.
set /p password=
if %password%==%password1% cls & goto :passed
goto :begin
:passed
echo Congratulations, you typed correct password.
pause>nul


Report •

#2
March 20, 2009 at 13:45:18
Thank you so much for answering me so soon! It worked
great!
Im just trying to learn about variables and such, so I was
trying to add a username aswell that had to be correct... but
if you type right username it just skips to the end of the bat
file without asking for password.. was wondering if you can
help me figure out whats wrong with this one:

echo off
cls
set username1=user123
set password1=pass123
:begin
echo Please enter Username
set /p username=
if %username%==%username1% cls & goto :passed1
goto :begin
passed1
echo Hello %username%, please type in password now.
set /p password=
if %password%==%password1% cls & goto :passed2
goto :begin
:passed2
echo Congratulations, you typed correct password and
username
Ping localhost -n 5 -w 1000 >nul
cls

Thanks for any reply =)


Report •

#3
March 20, 2009 at 15:35:23
Bah, sorry for posting that.. I had just forgot the : before
:passed1. Thanks anyways =)

Report •

Related Solutions

#4
March 20, 2009 at 20:58:06
Humm, Isn't having a password in a batch file and oxy moron?

It would be in my mind.


Report •

#5
March 21, 2009 at 00:13:17
@echo off & setLocal EnableDelayedExpansion

set user= & set pass=
set /p user=user name?
:pw
set /p pass=password?
if !pass! neq zzz goto :pw
echo OK


=====================================
If at first you don't succeed, you're about average.

M2


Report •


Ask Question