This page is edited from the 1cmdfaq.txt faq-file contained in
my tscmd.zip
command line interface (CLI) collection. That zipped file has much
additional material, including a number of detached .cmd script
files. It is recommended that you also get the zipped version as a
companion.
Please see "
The Description and
the Index page" for the conditions of usage and other such
information.
128} How to prevent SET /P input from entering the command history?
@echo off & setlocal enableextensions
set cmdfile=C:\_M\TEMP\temp$$$.cmd
> "%cmdfile%" echo @echo off
>> "%cmdfile%" echo set /p var_="Give your input? "
>> "%cmdfile%" echo echo %%var_%%
for %%c in ("cmd /c" del) do %%c "%cmdfile%"
endlocal & goto :EOF
Output
C:\_D\TEST>cmdfaq
Give your input? Hello World
Hello World
The "Hello World" is not in the command history.
Or use a call like
CMD /C myscript.cmd
Incidentally,
the first option could also be formulated as
@echo off & setlocal enableextensions
set cmdfile=C:\_M\TEMP\temp$$$.cmd
(
echo @echo off
echo set /p var_="Give your input? "
echo echo %%var_%%
)> "%cmdfile%"
for %%c in ("cmd /c" del) do %%c "%cmdfile%"
endlocal & goto :EOF