2

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
    )
Matt
  • 45,022
  • 8
  • 78
  • 119
HPC Enzo
  • 23
  • 4
  • Thanks! Yet one more wish, though. Couldn't you shorten your script up to the bare minimum needed to demonstrate your problem, please ? If I get you right, you're asking for how to clear the whole console command history from batch script. And if that is so, I don't see any reason to include so long (or any) script at all. – TLama Jan 13 '15 at 04:47
  • 1
    took out the code... correct i want to know how to clear the history in the script from previous set /p entry's – HPC Enzo Jan 13 '15 at 04:48
  • It sounds like you would be better off having a secure way of entering text in the first place - take a look at [this answer on another question](http://stackoverflow.com/questions/664957/can-i-mask-an-input-text-in-a-bat-file/20343074#20343074) – unclemeat Jan 13 '15 at 05:04
  • Also, you really need to include the relevant section of code. – unclemeat Jan 13 '15 at 05:09
  • I am not exactly sure how I would add this to my existing code. I am cutting out the exact section of code that is in question now. – HPC Enzo Jan 13 '15 at 05:20
  • added the section of code in question. – HPC Enzo Jan 13 '15 at 05:23
  • fixed needed to add doskey /reinstall – HPC Enzo Jan 13 '15 at 05:25
  • For the time being I do not see why PowerShell needs to be here. – Matt Jan 13 '15 at 05:40

1 Answers1

1

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
Gabe
  • 84,912
  • 12
  • 139
  • 238