我应该在哪里设置密码

时间:2017-06-20 14:32:11

标签: batch-file passwords hide mask

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

1 个答案:

答案 0 :(得分:0)

使用这个:

::By SachaDee - 2015
@echo off&cls

::the password
set $MDP=toto1234

for /f "delims=" %%a in ('powershell -c "$rep=read-host Enter your PWD -AsSecureString;$password = [Runtime.InteropServices.Marshal]::PtrToStringAuto([Runtime.InteropServices.Marshal]::SecureStringToBSTR($rep));write $password"') do set $rep=%%a
if %$MDP%==%$rep% (echo PWD ok) else (echo PWD not ok)
exit/b