Computing.Net > Forums > Windows XP > Hiding user input in batchfile

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Hiding user input in batchfile

Reply to Message Icon

Name: blink
Date: April 11, 2006 at 02:15:42 Pacific
OS: XP
CPU/Ram: P4/1GB
Product: HP
Comment:

I've created a batchfile that asks for a password to connect to an ftp with. This batch works perfectly all except for the fact that the password is visible when its typed in. Thus sharing it with everyone who can see the screen its on.

My question is; How do you hide user input in a batch file or even better. How do you show a * instead of the characters typed in. So you'll see '******' i.s.o. 'password'.



Sponsored Link
Ads by Google

Response Number 1
Name: IVO
Date: April 11, 2006 at 03:12:21 Pacific
Reply:

There's no way to achieve exactly what you wish under Windows XP/2K using batch facilities only.

A workaround is to set the background and text colors quite similar and restore them after typing the password, e.g.

Color 01
Statements to enter the password...
Color

To choose the preferred combination type Color /? and try to play.


0

Response Number 2
Name: Mechanix2Go
Date: April 11, 2006 at 03:50:20 Pacific
Reply:

This batch creates a util called input.com which it then uses to redirect input to file, set the password in a var called pw.

::== pwINPUT.bat
@echo off

call :make-it

echo pw ?
input>pw.txt
set /p pw=<pw.txt
type nul > pw.txt
del pw.txt
goto :eof

:make-it

> #.d echo E0100 B4 08 CD 21 88 C2 B4 02 CD 21 80 FA 0D 75 F1 B4
>> #.d echo E0110 4C CD 21 5B 2B D2 AC 3C
>> #.d echo N input.com
>> #.d echo RCX
>> #.d echo 0018
>> #.d echo W
>> #.d echo Q
debug < #.d > nul
del #.d
goto :eof
:: DONE

As IVO says, not much way to do it in plain NT.

Thanks to dtech10 for the nifty util.


=====================================
If at first you don't succeed, you're about average.

M2Go



0

Response Number 3
Name: blink
Date: April 12, 2006 at 07:20:24 Pacific
Reply:

IVO:

The color trick doesnt seem to work. At least not two the same colors which would hide the whole shebang.

Mechanix2Go:

It looks like it does what I want it too, but where does it dump the password? It doesnt have to be secure, just as long as it hides the input.


0

Response Number 4
Name: Mechanix2Go
Date: April 12, 2006 at 07:59:08 Pacific
Reply:

"This batch creates a util called input.com which it then uses to redirect input to file, set the password in a var called pw."


If at first you don't succeed, you're about average.

M2


0

Response Number 5
Name: IVO
Date: April 12, 2006 at 12:51:36 Pacific
Reply:

The Color trick is just a workaround as background and text can't be set to the same value (reported by the help).

I suggested to choose a pair of colors that make hard to view what you are typing if not just close to the screen. Color 01 may work in that way, but you have to issue a ClS just before restoring the default settings as Color affects ALL the window look not just the rows typed after it is set.

The sequence I suggest is

Echo Enter password
Color 01
Set /P PSW=
ClS
Color

where Color mn is at your choice


0

Related Posts

See More



Response Number 6
Name: blink
Date: April 13, 2006 at 00:07:42 Pacific
Reply:

IVO:

Yea thats what I noticed too, thanks.

Mechanix2Go:

How do I get the pass out again? When I echo the %pw% it doesnt show me anything. Might have to do with the fact that it gives an error saying #.d cant be opened, cause its in use.


0

Response Number 7
Name: Mechanix2Go
Date: April 13, 2006 at 01:01:03 Pacific
Reply:

Hi blink,

Are you running the batch at a CMD prompt?

NOT in a "run box".


If at first you don't succeed, you're about average.

M2


0

Response Number 8
Name: blink
Date: April 26, 2006 at 04:53:27 Pacific
Reply:

M2: I put it all in a batch file which I opened. Thats also the way I ultimately want to implement it.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Explorer Problem Black screen freeze befor...



Post Locked

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


Go to Windows XP Forum Home


Sponsored links

Ads by Google


Results for: Hiding user input in batchfile

User input in .bat Datei www.computing.net/answers/windows-xp/user-input-in-bat-datei/179546.html

Batch File with User Input www.computing.net/answers/windows-xp/batch-file-with-user-input/101175.html

Batch; User input to DIR www.computing.net/answers/windows-xp/batch-user-input-to-dir/83781.html