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

[分享]批处理调用VBS实现隐藏输入

个人认为:
1.  脚本和批处理是紧密结合的,灵活运用的话可以实现更丰富的功能。
2.  提倡模块化的写代码,以提高代码的重用性。
  1. @echo off
  2. echo 请输入:
  3. call :input mima
  4. echo 密码是:%mima%
  5. pause>nul
  6. exit
  7. :input
  8. :: (C)2010 Spring Brother
  9. :: 需要一个变量名作为参数
  10. echo WScript.StdOut.Write CreateObject("ScriptPW.Password").GetPassword > Spring
  11. cscript -nologo -e:vbs Spring > Brother
  12. set /p %1=<Brother
  13. del Spring,Brother
复制代码


或者可以少一个临时文件,更增加隐秘性:
  1. @echo off
  2. echo 请输入:
  3. call :input mima
  4. echo 密码是:%mima%
  5. pause>nul
  6. exit
  7. :input
  8. :: (C)2010 Spring
  9. :: 需要一个变量名作为参数
  10. echo WScript.StdOut.Write CreateObject("ScriptPW.Password").GetPassword > Spring
  11. for /f "delims=" %%z in ('cscript -nologo -e:vbs Spring') do set "%1=%%z"
  12. del Spring
复制代码

[ 本帖最后由 Spring 于 2010-1-28 13:06 编辑 ]

本帖最后由 pcl_test 于 2016-7-14 18:53 编辑

结合hta
  1. <!-- :
  2. @echo off
  3. for /f "delims=" %%a in ('mshta "%~f0"') do echo;%%a
  4. pause&exit
  5. -->
  6. <HTA:Application border='none' scroll='no' />
  7. <body style='text-align:center'><input id='pw' type='password' /><br/>输入完成按回车即可<script>
  8. window.resizeTo(200,80);
  9. document.onkeydown=function(){
  10.     if(window.event.keyCode == 13){
  11.         try{(new ActiveXObject('Scripting.FileSystemObject')).GetStandardStream(1).Write(document.getElementById('pw').value);}catch(e){}
  12.         window.close();
  13.     }
  14. }
  15. </script></body>
复制代码

TOP

本帖最后由 yu2n 于 2014-1-3 00:48 编辑

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

TOP

批处理输入密码但不显示(隐藏输入密码)
http://www.bathome.net/thread-4226-1-1.html

批处理输入密码但显示星号的代码之批处理应用版
http://www.bathome.net/thread-2130-1-1.html
我帮忙写的代码不需要付钱。如果一定要给,请在微信群或QQ群发给大家吧。
【微信公众号、微信群、QQ群】http://bbs.bathome.net/thread-3473-1-1.html
【支持批处理之家,加入VIP会员!】http://bbs.bathome.net/thread-67716-1-1.html

TOP

跟一个以前写的,要用到choice.exe
  1. @echo off&setlocal enabledelayedexpansion
  2. set "str=0 1 2 3 4 5 6 7 8 9 a b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z"
  3. for %%a in (%str%) do set /a n+=1&set ".!n!=%%a"
  4. :lp
  5. cls&set /p=请输入八位由数字和字母组成的密码,请注意大小写:<nul
  6. if defined pwds set /p=%pwds%<nul
  7. if "%m%" equ "8" echo.&echo.&goto next
  8. choice /n /cs /c %str: =%
  9. set "pwds=%pwds%*"&set "pwd=%pwd%!.%errorlevel%!"
  10. set /a m+=1&goto lp
  11. :next
  12. if "%pwd%" equ "BatHomes" (
  13.    echo 密码正确
  14.   ) else (
  15.    echo 密码错误
  16. )
  17. pause>nul
复制代码
***共同提高***

TOP

  1. : by Herbert Kleebauer
  2. :: 用途:输入密码时不在屏幕上显示出来
  3. :: electronixtar 转发 2007-1-16
  4. :: 来源:http://www.cn-dos.net/forum/viewthread.php?tid=26795
  5. ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  6. @echo off
  7. echo hP1X500P[PZBBBfh#b##fXf-V@`$fPf]f3/f1/5++u5x>in.com
  8. set /p password=Enter password:<NUL
  9. for /f "tokens=*" %%i in ('in.com') do set password=%%i
  10. pause
  11. del in.com
  12. echo.
  13. echo The Password is:"%password%"
  14. pause
复制代码

TOP

返回列表