Hiding Characters

Batch, ASP, JScript, Kixtart, etc.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Locked
User avatar
someguy
Posts: 7
Joined: Tue Jan 05, 2010 12:52 pm

Hiding Characters

Post by someguy »

Heres my script so far:

Code: Select all

@echo off
:a
set /p input=Name:
if %input%==Name goto b else goto c

:b
set /p pass=Password:
if %pass%==Pass goto d else goto c

:c
echo wrong
sleep 1
exit

:d
echo right
sleep 1
exit
so is there a way to hide whatever they type after "Name:" and "Password:"?

jvierra
Posts: 14543
Joined: Tue May 22, 2007 9:57 am
Contact:

Hiding Characters

Post by jvierra »

Not with a command line bat file.

You can do that with PowerShell and mosy other scripting languages.

Look for third party add-ons for the command line. Some may still be around although there is not much going on with the old DOS things anymore.

YOu can put teh following in a file with a vbs extension and get a password with no echo:

Code: Select all

	
Set oPW = CreateObject( "ScriptPW.Password" )
WScript.StdOut.Write "Enter password:"
sPW = oPW.GetPassword()
WScript.Echo vbCrLf & "You entered:" & sPW
	



See also:
http://blogs.technet.com/heyscriptinggu ... utbox.aspx


User avatar
someguy
Posts: 7
Joined: Tue Jan 05, 2010 12:52 pm

Hiding Characters

Post by someguy »

Thanks!

Locked