[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖
本帖最后由 yu2n 于 2014-1-3 00:49 编辑

windows 7 x64 下使用 BAT 调用 powershell 实现输入密码回显星号功能
http://stackoverflow.com/questio ... -text-in-a-bat-file
  1. @echo off
  2. set /p p= User Login - <nul
  3. call :_getPwd pwd
  4. echo Password is %pwd%
  5. pause
  6. goto :eof
  7. :_getPwd
  8.     REM powershell
  9.     (powershell /? >nul 2>nul) && powershell -Command $pword = read-host "Enter password" -AsSecureString ; ^
  10.         $BSTR=[System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($pword) ; ^
  11.             [System.Runtime.InteropServices.Marshal]::PtrToStringAuto($BSTR) > .tmp.txt
  12.             
  13.     REM VBS - ScriptPW.Password [C]2010 Spring
  14.     (powershell /? >nul 2>nul) || (
  15.         echo WScript.StdOut.Write CreateObject^("ScriptPW.Password"^).GetPassword > Spring
  16.         cscript -nologo -e:vbs Spring > .tmp.txt
  17.         del Spring
  18.     )
  19.     set /p %1=<.tmp.txt
  20.     del .tmp.txt
  21.     goto :eof
复制代码
『千江有水千江月』千江有水,月映千江;万里无云,万里青天。    http://yu2n.qiniudn.com/

TOP

返回列表