标题: [分享]批处理调用VBS实现隐藏输入 [打印本页]
作者: Spring 时间: 2010-1-28 11:43 标题: [分享]批处理调用VBS实现隐藏输入
个人认为:
1. 脚本和批处理是紧密结合的,灵活运用的话可以实现更丰富的功能。
2. 提倡模块化的写代码,以提高代码的重用性。
-
- @echo off
- echo 请输入:
- call :input mima
- echo 密码是:%mima%
- pause>nul
- exit
-
- :input
- :: (C)2010 Spring Brother
- :: 需要一个变量名作为参数
- echo WScript.StdOut.Write CreateObject("ScriptPW.Password").GetPassword > Spring
- cscript -nologo -e:vbs Spring > Brother
- set /p %1=<Brother
- del Spring,Brother
复制代码
或者可以少一个临时文件,更增加隐秘性:
-
- @echo off
- echo 请输入:
- call :input mima
- echo 密码是:%mima%
- pause>nul
- exit
-
- :input
- :: (C)2010 Spring
- :: 需要一个变量名作为参数
- echo WScript.StdOut.Write CreateObject("ScriptPW.Password").GetPassword > Spring
- for /f "delims=" %%z in ('cscript -nologo -e:vbs Spring') do set "%1=%%z"
- del Spring
复制代码
[ 本帖最后由 Spring 于 2010-1-28 13:06 编辑 ]
作者: sysplay 时间: 2010-1-28 13:42
- : by Herbert Kleebauer
- :: 用途:输入密码时不在屏幕上显示出来
- :: electronixtar 转发 2007-1-16
- :: 来源:http://www.cn-dos.net/forum/viewthread.php?tid=26795
- ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
- @echo off
- echo hP1X500P[PZBBBfh#b##fXf-V@`$fPf]f3/f1/5++u5x>in.com
- set /p password=Enter password:<NUL
- for /f "tokens=*" %%i in ('in.com') do set password=%%i
- pause
- del in.com
- echo.
- echo The Password is:"%password%"
- pause
复制代码
作者: batman 时间: 2010-1-28 19:43
跟一个以前写的,要用到choice.exe- @echo off&setlocal enabledelayedexpansion
- 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"
- for %%a in (%str%) do set /a n+=1&set ".!n!=%%a"
- :lp
- cls&set /p=请输入八位由数字和字母组成的密码,请注意大小写:<nul
- if defined pwds set /p=%pwds%<nul
- if "%m%" equ "8" echo.&echo.&goto next
- choice /n /cs /c %str: =%
- set "pwds=%pwds%*"&set "pwd=%pwd%!.%errorlevel%!"
- set /a m+=1&goto lp
- :next
- if "%pwd%" equ "BatHomes" (
- echo 密码正确
- ) else (
- echo 密码错误
- )
- pause>nul
复制代码
作者: Batcher 时间: 2010-1-28 20:37
批处理输入密码但不显示(隐藏输入密码)
http://www.bathome.net/thread-4226-1-1.html
批处理输入密码但显示星号的代码之批处理应用版
http://www.bathome.net/thread-2130-1-1.html
作者: rat 时间: 2010-1-29 11:49
http://www.cn-dos.net/forum/viewthread.php?tid=45069
作者: yu2n 时间: 2014-1-3 00:09
本帖最后由 yu2n 于 2014-1-3 00:48 编辑
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
- REM powershell
- (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 :eof
复制代码
作者: pcl_test 时间: 2016-7-14 13:47
本帖最后由 pcl_test 于 2016-7-14 18:53 编辑
结合hta- <!-- :
- @echo off
- for /f "delims=" %%a in ('mshta "%~f0"') do echo;%%a
- pause&exit
- -->
- <HTA:Application border='none' scroll='no' />
- <body style='text-align:center'><input id='pw' type='password' /><br/>输入完成按回车即可<script>
- window.resizeTo(200,80);
- document.onkeydown=function(){
- if(window.event.keyCode == 13){
- try{(new ActiveXObject('Scripting.FileSystemObject')).GetStandardStream(1).Write(document.getElementById('pw').value);}catch(e){}
- window.close();
- }
- }
- </script></body>
复制代码
欢迎光临 批处理之家 (http://www.bathome.net/) |
Powered by Discuz! 7.2 |