Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
565 views
in Technique[技术] by (71.8m points)

What would be the Windows batch equivalent for HTML's input type="password"?

I need to get authentication credentials from the users within a Windows script but the classic "first Google result" approach:

SET /P USR=Username: 
SET /P PWD=Password: 

is less than satisfying, so I was wondering if there's let's say an "equivalent" to HTML's input type="password"?

Any comment would be really appreciated, thanks much in advance!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

check out this

http://www.netikka.net/tsneti/info/tscmd052.htm

@echo off & setlocal enableextensions
    :: Build a Visual Basic Script
    set vbs_=%temp%mp$$$.vbs
    set skip=
    findstr "'%skip%VBS" "%~f0" > "%vbs_%"
    ::
    :: Prompting without linefeed as in Item #15
    echo.|set /p="Password: "

    :: Run the script with Microsoft Windows Script Host Version 5.6
    for /f "tokens=* delims=" %%a in ('cscript //nologo "%vbs_%"') do set MyPass1=%%a

    ::
    ::echo.
    echo.|set /p="Retype  : "

    for /f "tokens=* delims=" %%a in ('cscript //nologo "%vbs_%"') do set MyPass2=%%a
    ::

    :: Clean up
    for %%f in ("%vbs_%") do if exist %%f del %%f
    ::
    :: Demonstrate the result
    echo.
    if "%MyPass1%"=="%MyPass2%" (
      echo The entered password was %MyPass1%
      ) else (
      echo No match)
    endlocal & goto :EOF
    '
    'The Visual Basic Script
    Set WshPass = WScript.CreateObject("ScriptPW.Password") 'VBS
    Password=WshPass.GetPassWord() 'VBS
    WScript.Echo PassWord 'VBS

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...