@echo off
color 3a
title 输入密码显示星号批处理
echo.
echo.
echo 还有一个难题未解决:就是密码必须是指定个数的字母或数字!
echo.
echo 本演示程序指定密码字符限制为8个
echo.
echo 默认用户名是guest。请设置密码。用户名和密码不区分大小写。
pause
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::在下面输入密码,输入后跳转到编译模块,将choice的返回码编译成输入的字符::
::之后跳转到下一个字符并在屏幕输出上加一个星号字符。并把密码保存到文件。::
::使用时可以美化界面,甚至做成和正规程序差不多的登陆界面。保存密码的文件::
::也可以保存到隐秘的位置或者网络路径。甚至还可以按一定的算法把密码保存成::
::加密的,登录时再进行反运算恢复。原来我还想加入退格符使它可以有退格删除::
::的功能,但是choice的选项只能是字母和数字,只好作罢。为保持代码整洁凑字::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:pass
cls
set jindu=1
choice /c 1234567890abcdefghijklmnopqrstuvwxyz /m 请输入密码: /n
goto bianyi
:1
cls
set jindu=2
choice /c 1234567890abcdefghijklmnopqrstuvwxyz /m 请输入密码:* /n
goto bianyi
:2
cls
set b=%a%
set jindu=3
choice /c 1234567890abcdefghijklmnopqrstuvwxyz /m 请输入密码:** /n
goto bianyi
:3
cls
set c=%a%
set jindu=4
choice /c 1234567890abcdefghijklmnopqrstuvwxyz /m 请输入密码:*** /n
goto bianyi
:4
cls
set d=%a%
set jindu=5
choice /c 1234567890abcdefghijklmnopqrstuvwxyz /m 请输入密码:**** /n
goto bianyi
:5
cls
set e=%a%
set jindu=6
choice /c 1234567890abcdefghijklmnopqrstuvwxyz /m 请输入密码:***** /n
goto bianyi
:6
cls
set f=%a%
set jindu=7
choice /c 1234567890abcdefghijklmnopqrstuvwxyz /m 请输入密码:****** /n
goto bianyi
:7
cls
set g=%a%
set jindu=8
choice /c 1234567890abcdefghijklmnopqrstuvwxyz /m 请输入密码:******* /n
goto bianyi
:8
cls
echo 请输入密码:********
if '%login%'=='1' goto yanzheng
set h=%a%
echo %a%%b%%c%%d%%e%%f%%g%%h% >password
echo 密码设置成功,即将转到登陆界面!
ping 127.1>nul&goto login
:bianyi
if %errorlevel% lss 10 set a=%errorlevel%&&goto %jindu%
if '%errorlevel%'=='10' set a=0
if '%errorlevel%'=='11' set a=a
if '%errorlevel%'=='12' set a=b
if '%errorlevel%'=='13' set a=c
if '%errorlevel%'=='14' set a=d
if '%errorlevel%'=='15' set a=e
if '%errorlevel%'=='16' set a=f
if '%errorlevel%'=='17' set a=g
if '%errorlevel%'=='18' set a=h
if '%errorlevel%'=='19' set a=i
if '%errorlevel%'=='20' set a=j
if '%errorlevel%'=='21' set a=k
if '%errorlevel%'=='22' set a=l
if '%errorlevel%'=='23' set a=m
if '%errorlevel%'=='24' set a=n
if '%errorlevel%'=='25' set a=o
if '%errorlevel%'=='26' set a=p
if '%errorlevel%'=='27' set a=q
if '%errorlevel%'=='28' set a=r
if '%errorlevel%'=='29' set a=s
if '%errorlevel%'=='30' set a=t
if '%errorlevel%'=='31' set a=u
if '%errorlevel%'=='32' set a=v
if '%errorlevel%'=='33' set a=w
if '%errorlevel%'=='34' set a=x
if '%errorlevel%'=='35' set a=y
if '%errorlevel%'=='36' set a=z
goto %jindu%
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::::::::::::::::::::::::::以下是登陆模块:::::::::::::::::::::::::::::::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:login
cls
set login=1
echo 默认用户名是guest。用户名和密码不区分大小写。
set name=
set /p name=请输入用户名:
if /i '%name%'=='guest' goto pass
if /i not '%name%'=='guest' echo 用户名输入错误,请按任意键重新输入!&pause>nul&goto login
:yanzheng
set a=%a%%b%%c%%d%%e%%f%%g%%h%
for /f %%p in (password) do set p=%%p
if /i '%a%'=='%p%' echo 密码正确,登陆成功!&ping 127.1>nul&goto start
echo 密码错误,请重新输入!&ping 127.1>nul&goto pass
pause>nul&exit
:start
cls
echo 这里是程序正文......
echo 演示结束,按任意键退出...
pause>nul&exit作者: Orilla 时间: 2008-3-24 17:04 说支持必须得过来支持。。。。。呵呵作者: yuseecn 时间: 2008-3-28 18:13 支持作者: Shinaterry 时间: 2008-3-30 12:40 支持, 希望继续完善..作者: bat-zw 时间: 2008-3-30 13:16 标题: 加油,大家共同提高: