I have some code inside a batch file that when I run it my passwords do get hidden. However I am trying to build it so that I can place the code inside any batch file and you will then need to enter the correct password. Currently you can type anything and be allowed access. I know my code isn't written so you have to type something specific in, that is why I am asking here.
@echo off
set "psCommand=powershell -Command "$pword = read-host 'Enter Password' -
AsSecureString ; ^
$BSTR=[System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($pword); ^
[System.Runtime.InteropServices.Marshal]::PtrToStringAuto($BSTR)""
for /f "usebackq delims=" %%p in (`%psCommand%`) do set password=%%p
echo %password%
I wish to keep my code as it is because it currently hides what gets typed, but I need someone to add some sort of password checker.