命令行输入密码以星号*显示

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

  pause

以bat形式运行

命令行输入密码以星号*显示_第1张图片

你可能感兴趣的:(命令行输入密码以星号*显示)