Computing.Net > Forums > Programming > batch file environment variables

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

batch file environment variables

Reply to Message Icon

Name: esteban
Date: February 3, 2008 at 14:45:26 Pacific
OS: Windows Vista Home Premiu
CPU/Ram: Intel Core 2 Duo @ 2.67 G
Product: Dell XPS 410
Comment:

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 stop

I 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: stop

C:\>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?



Sponsored Link
Ads by Google

Response Number 1
Name: klint
Date: February 3, 2008 at 15:34:53 Pacific
Reply:

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


0

Response Number 2
Name: esteban
Date: February 3, 2008 at 16:25:30 Pacific
Reply:

Wow, I can't believe I didn't notice that before. Thanks a ton!


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

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


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: batch file environment variables

batch file: error SETting in FOR /f www.computing.net/answers/programming/batch-file-error-setting-in-for-f/16520.html

Batch file www.computing.net/answers/programming/batch-file/18005.html

Batch File Save Game www.computing.net/answers/programming/batch-file-save-game/19255.html