Cmd input text color

Microsoft Windows
Post Reply
User avatar
MigrationUser
Posts: 336
Joined: 2021-Jul-12, 1:37 pm
Contact:

Cmd input text color

Post by MigrationUser »

14 Aug 2015 23:10
Batcher

Is there a way to make user input into a batch file black text rather than the color of the text being displayed n the screen

----------------------------

#2 14 Aug 2015 23:13
Batcher

For example using the code

Code: Select all

@ECHO OFF
cls
Color 02
Echo enter password
set/p "ch@ECHO OFF
title Folder Private
if EXIST "HTG Locker" goto UNLOCK
if NOT EXIST Private goto MDLOCKER
:CONFIRM
echo Are you sure you want to lock the folder(Y/N)
set/p "pass=>" INPUT IS BLACK TEXT SO YOU CANT SEE IT.
----------------------------

#3 15 Aug 2015 04:11
Shadow Thief


oldforum/viewtopic.php?id=1682 may help.

Alternatively, you can use xcopy to simply mask the input: https://www.dostips.com/forum/viewtopic ... 788#p26788 (I personally prefer this method, and I use a variation of it on almost a daily basis.)

----------------------------

#4 15 Aug 2015 10:31
npocmaka

Here you can find few ways to do this : https://stackoverflow.com/questions/433 ... batch-file

----------------------------
#5 15 Aug 2015 22:51
Batcher

But can I change the color of what the user types as they type it rather than masking the password

----------------------------
#6 15 Aug 2015 23:19
npocmaka

The simplest way I suppose will be to use .net and Console.ReadKey() + Console.BackgroundColor / Console.ForegroundColor.

You can combine jscript.net and batch like shown here - http://www.dostips.com/forum/viewtopic.php?f=3&t=5260

----------------------------
#7 17 Aug 2015 17:33
npocmaka

Check this .

With this script the text input will be colored.though the colors will be lost if the script is redirected , piped or processed with FOR /F.
But I suppose you'll want to preserve the output. The only option that I found working was (optional) writing to a file (later you can read it).

----------------------------

#8 25 Aug 2015 01:27
Batcher

Hi every one I know it is invald but is there any way to use the cmd command color 00 to make both text and the background black ?

----------------------------
#9 25 Aug 2015 03:57
Shadow Thief

Can't be done, unfortunately. It's worth noting that that's a feature, not a bug.

----------------------------

#10 25 Aug 2015 04:00
Shadow Thief

In retrospect I probably should have asked this a while ago, but what is your overall objective? If you're changing the text to match the same color as the background, that's really the same as masking the input via the second link in my first post.

----------------------------

#11 25 Aug 2015 09:41
npocmaka
Batcher wrote:

Hi every one I know it is invald but is there any way to use the cmd command color 00 to make both text and the background black ?
Have you checked my previous post?
with the script in the link there's no problem to make input colors 00.

Though if you want to hide the user input - check this http://stackoverflow.com/a/24396213/388389

----------------------------

#12 25 Aug 2015 13:05
Batcher

npocmaka using your colorinput tool what is the command syntax for color 00

----------------------------

#13 25 Aug 2015 15:55
npocmaka
Batcher wrote:

npocmaka using your colorinput tool what is the command syntax for color 00

Code: Select all

call colorinput.bat -f 0 -b 0 -o resultFile.txt
-o resultFile can be omitted - its put in case you want a further processing of the input data ( no way to directly be assigned to variable)

Last edited by npocmaka (25 Aug 2015 15:56)
Post Reply