-1

Is there a way to make a variable to show dots. (not make it to just show it) like:

set=password=code
echo password=%password%

Then it show:

password=****
  • 1
    You could count the characters in password and build a new variable with the same count of asterix – jeb Dec 21 '21 at 12:01
  • It need to get the numbers from the password because if the user it change the password it need to change to. – Jonas Lindberg Dec 21 '21 at 12:09
  • 1
    That is my point about counting the characters, you could use [:strlen](https://stackoverflow.com/q/5837418/463115) for that – jeb Dec 21 '21 at 12:16
  • thanks for that now I have the number 4 and need to have xxxx. can you help with that – Jonas Lindberg Dec 21 '21 at 12:51

1 Answers1

0

If you know the length of the password (could be retrieved with :strlen), then you only need to add one asterix per count.

setlocal EnableDelayedExpansion

call :strlen password pwd_length

set "masked_pwd="
FOR /L %%n in (1 1 !pwd_length!) do set "masked_pwd=!masked_pwd!*"
jeb
  • 74,839
  • 15
  • 166
  • 215