mask a password inputed in a batch file

@echo off
powershell -Command $pword = read-host "Enter password" -AsSecureString ; $BSTR=[System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($pword) ; [System.Runtime.InteropServices.Marshal]::PtrToStringAuto($BSTR) > .tmp.txt & set /p password=<.tmp.txt & del .tmp.txt
echo %password%
  • tech-notes/scripts/mask-password-in-a-batch-file.txt
  • Last modified: 2018/05/17 20:05
  • by gerardorourke