批处理文件替换输入*无需外部文件 [英] batch file to replace the input with * without external file
问题描述
我需要批处理文件来屏蔽输入与*没有外部文件,我需要code到((((是快写字母))))),并且不与计算的距离*
((((如果有code从批处理文件,它使外部文件中提取外部文件做出与*和快速的密码写密码添加评论见code))))
例如:
关闭@echo
设置字符= *
集/ p变量=输入你的密码:
字符集=%变量%
回声%字符%
暂停
这是一个在code你在previous问题得到清理。如果这不是你不够快,那么你应该考虑不这样做批处理,并使用一些aditional的工具。
关闭@echo
SETLOCAL ENABLEEXTENSIONS disabledelayedexpansionREM子程序调用以获取密码
拨打:getPassword来密码REM回声什么函数返回
如果定义的密码(
回声您键入[%密码%]
)其他(
回声您键入什么
)该方法的REM完
ENDLOCAL
退出/ B
REM子程序来获取密码
:getPassword来returnVar
SETLOCAL ENABLEEXTENSIONS disabledelayedexpansion
设置_password = REM我们需要一个退格处理字符去除
FOR / F %%一个在('的提示; $的H&在(0)做REM %% B)并设置BS = %%一个 REM提示用户
集/ P=密码:< NUL:keyLoop
REM检索键preSS
设置键=
FOR / Fdelims =%%一个在('XCOPY / L / W%〜F0%〜F02 ^> NUL')不要。如果没有定义键设置键= %%一个
设置键=%键:〜-1% REM处理关键preSS
REM如果没有关键preSS(进入),然后退出
REM若退格,从密码和控制台中删除角色
REM添加其他字符的密码并要求下一个
如果自定义键(
如果%键%==BS%%(
如果定义_password(
设置_password =%_密码:〜0,-1%。
SETLOCAL enabledelayedexpansion&安培;集/ P= BS BS!!!<&NUL放大器; ENDLOCAL
)
)其他(
设置_password =%_密码%%键%
集/ P= *< NUL
)
转到:keyLoop
)
回声(
REM回归密码呼叫者
如果定义_password(设置退出code = 0),其他(设置退出code = 1)
ENDLOCAL&安培;集%〜1 =%_密码%&放大器;退出/ B%出口code%
i need batch file to mask the input with * without external file and i need the code to ((((be fast in write letters))))) and does not Calculates the distance with *
((((if there is code extract the external file from the batch file which make the external file make password with * and fast to write password add comment to see the code ))))
FOR EXAMPLE:
@echo off
set char=*
set /p variable=Enter your password:
set char=%variable%
echo %char%
pause
This is a "cleanup" of the code you get in your previous question. If this is not fast enough for you, then you should consider not doing it in batch and use some aditional tool.
@echo off
setlocal enableextensions disabledelayedexpansion
rem Call the subroutine to get the password
call :getPassword password
rem Echo what the function returns
if defined password (
echo You have typed [%password%]
) else (
echo You have typed nothing
)
rem End of the process
endlocal
exit /b
rem Subroutine to get the password
:getPassword returnVar
setlocal enableextensions disabledelayedexpansion
set "_password="
rem We need a backspace to handle character removal
for /f %%a in ('"prompt;$H&for %%b in (0) do rem"') do set "BS=%%a"
rem Prompt the user
set /p "=password ?:" <nul
:keyLoop
rem retrieve a keypress
set "key="
for /f "delims=" %%a in ('xcopy /l /w "%~f0" "%~f0" 2^>nul') do if not defined key set "key=%%a"
set "key=%key:~-1%"
rem handle the keypress
rem if No keypress (enter), then exit
rem if backspace, remove character from password and console
rem else add character to password and go ask for next one
if defined key (
if "%key%"=="%BS%" (
if defined _password (
set "_password=%_password:~0,-1%"
setlocal enabledelayedexpansion & set /p "=!BS! !BS!"<nul & endlocal
)
) else (
set "_password=%_password%%key%"
set /p "=*"<nul
)
goto :keyLoop
)
echo(
rem return password to caller
if defined _password ( set "exitCode=0" ) else ( set "exitCode=1" )
endlocal & set "%~1=%_password%" & exit /b %exitCode%
这篇关于批处理文件替换输入*无需外部文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!