Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I am trying to set environment variables with batch files by getting user input, something like this:
set /p input = "Type something here: "
echo You typed %input%.
if "%input%" == "stop" goto stopI run the file without @echo off at the beginning, for debugging. The output looks something like this:
C:\>test.bat
C:\>set /p input = "Type something here: "
Type something here: stopC:\>echo You typed .
You typed .C:\>if "" == "stop" goto stop
So basically the variable isn't getting stored properly for some reason. But the galling thing is that if I go back to the command line and check the environment variables with set, the variable input IS defined, and it contains "stop". Any reason why this might be happening?

Yes, the variable you are setting is called "input " (ending with a space) but you are trying to use "input" (without a space.)

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |