Friday, February 16, 2018

Hide password in Command prompt


@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%

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.