Prevent Password From Being Echoed

  • Thread starter Thread starter BDB
  • Start date Start date
B

BDB

Hi,

I'm new here and I'm sure this has been asked before.

I have a script that prompts for a password with something like this:

set /P pass="Password: "

How do I prevent the password from being echoed to the screen while it is
typed?


Thank you,
Bryan
 
BDB said:
I'm new here and I'm sure this has been asked before.

I have a script that prompts for a password with something
like this:

set /P pass="Password: "

How do I prevent the password from being echoed to the screen
while it is typed?
Hi,

With set /P, that is not possible.


A couple of other options:

1)
WBAT supports password input it looks like:
http://home.mnet-online.de/horst.muc/main.htm


2)
As long as you are running Windows XP (will not work for Win2k),
you can use this:

--------------------8<----------------------
@echo off
setlocal

set tmpfile="%tmp%\pw.vbs"
echo WScript.Echo CreateObject("ScriptPW.Password").GetPassword() >%tmpfile%

echo Enter password and then press Enter:
for /f "tokens=*" %%a in (
'cscript.exe //Nologo %tmpfile%') do set result=%%a

del %tmpfile%
echo.
echo Password is: %result%
echo.

endlocal
pause

--------------------8<----------------------
 
Torgeir Bakken (MVP) said:
Hi,

With set /P, that is not possible.


A couple of other options:

1)
WBAT supports password input it looks like:
http://home.mnet-online.de/horst.muc/main.htm


2)
As long as you are running Windows XP (will not work for Win2k),
you can use this:

--------------------8<----------------------
@echo off
setlocal

set tmpfile="%tmp%\pw.vbs"
echo WScript.Echo CreateObject("ScriptPW.Password").GetPassword()

echo Enter password and then press Enter:
for /f "tokens=*" %%a in (
'cscript.exe //Nologo %tmpfile%') do set result=%%a

del %tmpfile%
echo.
echo Password is: %result%
echo.

endlocal
pause

Thank you. This was helpful.
 
BDB said:
Hi,

I'm new here and I'm sure this has been asked before.

I have a script that prompts for a password with something like this:

set /P pass="Password: "

How do I prevent the password from being echoed to the screen while it is
typed?

Poor man's version:

echo/Before actually entering the password, drag this window
echo/down so that when the password you type is displayed
echo/it will be off screen.
(set/p pass=Enter the password: )
cls
title drag this window back up so you can see it again.


/Al
 
Hi,

I'm new here and I'm sure this has been asked before.

I have a script that prompts for a password with something like this:

set /P pass="Password: "

How do I prevent the password from being echoed to the screen while it is
typed?


Thank you,
Bryan

See tip 8610 » How can I prevent a script from echoing a user's response?
in the 'Tips & Tricks' at http://www.jsifaq.com
 
Back
Top