本帖最后由 yu2n 于 2014-1-3 00:49 编辑
windows 7 x64 下使用 BAT 调用 powershell 实现输入密码回显星号功能
http://stackoverflow.com/questio ... -text-in-a-bat-file | @echo off | | set /p p= User Login - <nul | | call :_getPwd pwd | | echo Password is %pwd% | | pause | | goto :eof | | | | | | :_getPwd | | | | (powershell /? >nul 2>nul) && powershell -Command $pword = read-host "Enter password" -AsSecureString ; ^ | | $BSTR=[System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($pword) ; ^ | | [System.Runtime.InteropServices.Marshal]::PtrToStringAuto($BSTR) > .tmp.txt | | | | REM VBS - ScriptPW.Password [C]2010 Spring | | (powershell /? >nul 2>nul) || ( | | echo WScript.StdOut.Write CreateObject^("ScriptPW.Password"^).GetPassword > Spring | | cscript -nologo -e:vbs Spring > .tmp.txt | | del Spring | | ) | | set /p %1=<.tmp.txt | | del .tmp.txt | | goto :eofCOPY |
|