Prevent Password From Being Echoed

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
 
T

Torgeir Bakken \(MVP\)

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<----------------------
 
B

BDB

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.
 
A

Al Dunbar [MS-MVP]

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
 
J

Jerold Schulman

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top