<http://www.netikka.net/tsneti/info/tscmd128.htm>
Copyright © 2003-2013 by Prof. Timo Salmi  
Last modified Tue 3-Dec-2013 18:46:49

 
Assorted NT/2000/XP/.. CMD.EXE Script Tricks
From the html version of the tscmd.zip 1cmdfaq.txt file
To the Description and the Index
 

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

References/Comments: (If a Google message link fails try the links within the brackets.)
  Google Groups Jan 7 2006, 6:03 pm [M]