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.
This topic is 14 years and 2 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
someguy
Posts: 7
Last visit: Sun Jan 10, 2010 1:18 am

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: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

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
Last visit: Sun Jan 10, 2010 1:18 am

Hiding Characters

Post by someguy »

Thanks!
This topic is 14 years and 2 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked