prompt Optional input prompt for the /P name= option.
Looks like if you remove the spaces in the prompt set 'prompts' for input, but still doesn't set the variable. If you remove the prompt entirely it works:
Code:
unset choice
set /p choice=Enteryourchoice: & echo choice === choice%
fred
choice ===
set /p choice= & echo choice === %choice%
gtrf
choice === gtrf
Note that SET /P is intended solely for CMD compatibility, but your example will not work with CMD (because CMD will expand the variable before you enter it).
Thanks Rex. I'm sure the OP (rps) appreciates your speedy work as well :) . I noticed the 'CMD expanding variable before set on same cmdline' thing and meant to mention it too, but of course that's only an issue with the echo output. The real issue was with the 'set /p' part which does work as written with CMD... I'm guessing rps made the example as a quick one liner for demonstration purposes only under TCC.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.