windows - 批处理脚本帮助清除历史记录不是 cls 的问题

标签 windows batch-file cmd batch-processing

我当前的问题是在 :menua 标签之前。我需要清除之前输入的所有条目。我得到它来清除历史记录中的密码,但我希望从输入历史记录中清除所有内容。我知道您可以使用 ALT+F7 清除,但我希望自动完成此操作以清除用户名条目。那么历史就没有任何内容了。 ...欢迎任何其他使这个更好的编辑/建议与修复分开。

set/p loginname 是我想要保护的。

: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
    )

最佳答案

要清除历史,使用

doskey /listsize=0

然后允许创建新的历史记录(假设之前的大小为 50):

doskey /listsize=50

关于windows - 批处理脚本帮助清除历史记录不是 cls 的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27914771/

相关文章:

c++ - std::stringstream 类需要有 dll 接口(interface)

python - 使用管理员权限打开 cmd (Windows 10)

windows - 如何在Windows Batch中回显>不带引号的字符? [复制]

windows - Echo 在我的 Windows 批处理脚本中无法正常工作

windows - 如何将linux批处理文件转换为windows bat文件?

windows - 如何成功地将 For 循环回显到批处理脚本中?

node.js - Node 应用程序作为 Windows 10 上的 Windows 服务

windows - 使用批处理文件运行快捷方式

cmd - 我如何在 cmd 或命令提示符中插入此 ascii 文本艺术?

Windows 上下文菜单运行隐藏的 xcopy