Disable command history in a Windows batch file

Is it possible to disable command history in a batch file?

After calling my.bat, the results from calls to things like SET /P are entered into the history. Therefore, if I ask my user to enter a machine name, the history now also contains that machine name.

P:> my.bat

P:> SET / P MYENV = "myenv prompt:"

myenv prompt: lskdjf

P:> lskdjf

P:>

DOSKEY does not seem to be able to pause or disable the history stack click.

+4
source share
1 answer

Short answer

 doskey /reinstall 

This destroys the full story.

The second method could also start a new instance of cmd.exe in your batch, this will delete the history made by your set/p statements.

 @echo off if "%~1"==":historySafe" goto :historySafe cmd /c "%~f0" :historySafe exit /b :historySafe set /p var=Password echo %var% exit /b 
+8
source

Source: https://habr.com/ru/post/1401600/


All Articles