Reputation: 23
My current issue is before the :menua
tag. I need all previous entries typed to be cleared. I got this to work to clear the password from the history but I want everything cleared from the input history. I know you can clear using ALT+F7 but I want this done automatically to clear the username entry. Then the history would have nothing in it.
... Any other edits/recommendations to make this better are welcome just keep separate from the fix.
The set /p loginname
is what i want to secure.
:login
call :ColorText 0c " Type owner to find the owners contact info."
echo.
echo.
call :ColorText 0c " Username"
echo. <nul
SET /P loginname=
if "%loginname%"=="owner" goto :owner
:L5
call :ColorText 0c " Password"
echo. <nul
:HInput
SetLocal DisableDelayedExpansion
Set "password="
Rem Save 0x08 character in BS variable
For /F %%# In (
'"Prompt;$H&For %%# in (1) Do Rem"'
) Do Set "BS=%%#"
:HILoop
Set "Key="
For /F "delims=" %%# In (
'Xcopy /L /W "%~f0" "%~f0" 2^>Nul'
) Do If Not Defined Key Set "Key=%%#"
Set "Key=%Key:~-1%"
SetLocal EnableDelayedExpansion
If Not Defined Key Goto :HIEnd
If %BS%==^%Key% (Set /P "=%BS% %BS%" <Nul
Set "Key="
If Defined password Set "password=!password:~0,-1!"
) Else Set /P "=*" <Nul
If Not Defined password (EndLocal &Set "password=%Key%"
) Else For /F delims^=^ eol^= %%# In (
"!password!") Do EndLocal &Set "password=%%#%Key%"
Goto :HILoop
:HIEnd <nul
Echo( <nul
Echo Your password is '!password!' <nul
Pause <nul
Goto :pass
:pass
if "%loginname%"=="username" (
goto :password1
) else (
cls
goto :login
)
Upvotes: 2
Views: 157
Reputation: 86718
To clear the history, use
doskey /listsize=0
Then to allow a new history to be created (assuming the previous size was 50):
doskey /listsize=50
Upvotes: 1