Fixed Win "set /p" not working in V17 build 53

rps

Jul 6, 2008
293
4
#1
Set /p isn't working in V17.00.53 x64

Code:
D:\bat>set /p choice="Enter your choice: " & echo choice === %choice%
^C

D:\bat>ver

TCC  17.00.53 x64   Windows 7 [Version 6.1.7601]


D:\bat>set /p choice="Enter your choice: " & echo choice === %choice%
^C

D:\bat>
Works in V16.03.55 x64
Code:
C:\JPSoft\tcmd16x64>ver

TCC  16.03.55 x64   Windows 7 [Version 6.1.7601]


C:\JPSoft\tcmd16x64>set /p choice="Enter your choice: " & echo choice === %choice%
"Enter your choice: "3
choice === 3


C:\JPSoft\tcmd16x64>
 

gwgaston

Senior IT Security Consultant
May 28, 2008
40
1
SC
#2
Confirmed here too... although it doesn't hang, but returns a double usage error message:

Code:
Usage : SET [/A /D /E /O /P /R file... /RO /S /U /V /X] [name[=][value ]]
Usage : SET [/A /D /E /O /P /R file... /RO /S /U /V /X] [name[=][value ]]
ref Help:

Definition mode:


SET [/A /D /O /S /U /V /E /RO /R [file...] | name=value | prompt ]

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
 

gwgaston

Senior IT Security Consultant
May 28, 2008
40
1
SC
#4
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.