Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I'm trying to write a batch file that accepts a password as input (to go into an env variable) but I don't know how to have it either not echo or echo astrixes (***) instead of what is actually typed. Can anyone share some wisdom?

Haven't a clue.....but if you use the ansi.sys, you could have the input be the same color as the background and thus invisable.
Ok befor I get zapped for this "inviso stuff" it is just off the top of my head.
W.L.

Hi.
WL is right, that's a way to do it. I have developed a batch file just like that.
ANSI.SYS MUST BE LOADED INTO MEMORY.
Check if there's a line refeering to it at config.sys (should be something like "DEVICE=C:\WINDOWS\COMMAND\ANSI.SYS)
If there isn't such a string, add it (make a search for ansi.sys into your computer and then enter the right path into the line)Ok, here's the batch. I'm assuming you're using an english dos. If not, letmeknow.
::pass3.bat
@echo off
:loop
SET PASS=
echo on
prompt $e[=0m
prompt $e[=37m
prompt $e[=40m
echo off
cls
echo *** Type password ***
prompt $e[=0m
prompt $e[=37m
prompt $e[=47m
echo on
REM ----------------------------------------------------------------------------
@echo off
FC nul con /n /lb1 |DATE |find "1:">OUT.BAT
ECHO SET PASS=%%5> enter.bat
call out.bat
if not "%PASS%"=="abc123" goto loop
SET PASS=
del enter.bat
echo on
prompt $e[=40m
prompt $P$G
clsThe password for that batch is abc123.
Any further questions, letmeknow
please keep me informed of your progress!-- Secret_Doom --
email: secret_doom@hotmail.com
PS: I must warn ya: batch files don't offer any security at all. You can't stop user from editing the batch and find out the password. I has only effects if you're looking for security against dossed persons.

...about this part:
REM ----------------------------------------------------------------------------
that's one single line...

Here is one that illustrates the masking you are after:
http://home7.inet.tele.dk/batfiles/monthly/jul2000.htmTrue, you can also use ansi.sys for masking effect. You can also use an echo command which does not include the CR/LF (carriage return/line feed) characters, such as here:
http://home7.inet.tele.dk/batfiles/main/batchfaq.htm#79Secret_Doom is right about a password batch file not being too secure, but it also depends on where and how it is used. In some cases it is very secure.
Here is a version of input.bat which includes a verification.
http://home7.inet.tele.dk/batfiles/main/batchfaq.htm#input2.bat

If you just want to hide keyboard input,
you can also set screen colors to black on
black (for example) with ansi.sys.Choice may also be used.

Guys, I appreciate your input. Let me give you a little more info on what I'm trying to do. This file will help me logon to an NT domain in dos so I can build machines with Ghost. NT will be authenticating the password so I need to put password into an environmental variable that can load at the end of the boot process. I'm not concerned with security because the temp file that contains the password is deleted before anyone else gets to the machine. The batch file works fine now, I just get ribbing from my co-workers because their password echos to the screen when they use it to attach to the network. After I submitted this question, I found batchman.com that lets me move the cursor to off the screen (line 26) while they enter their password, & that's acceptable, but I'd still like to use *** instead of actual input. I'll put a Reader's Digest version in another follow-up.

Here is what I have now.
It uses be.exe & getvar if your familiar.
Either way I think the logic is easy to follow.
------------------------------------------
echo off
cls%bepath%\be.exe rowcol 12 20 "Enter your LanID: " green
%bepath%\getvar userid > %bepath%\STDOUT.BAT%bepath%\be.exe rowcol 16 20 "Enter your password: " green
a:\BATCHMAN setcursor 26,22
%bepath%\getvar password >> %bepath%\STDOUT.BATCALL %bepath%\STDOUT.BAT
DEL %localpath%\STDOUT.BAT

![]() |
Batch File Variables
|
himem.sys
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |