Anonymous
Anonymous

Reputation: 3

Inputting a variable into a text file, using a batch file

So I'm trying to make it so that the user sets a password, and that password is loaded into a text file to be extracted for later use. The problem is, instead of typing the variable that the user inputs in the text file, it types 'ECHO is off' (or ECHO is on, if it's on).

Here is what I have written.

cls
set/p pass = Please enter your password:
> "p.txt" (@echo %pass%)
echo Password created!

Thanks in advance!

EDIT: Thanks to MC ND, I have the solution! set /p "pass= Please enter your password:"

Upvotes: 0

Views: 384

Answers (1)

MC ND
MC ND

Reputation: 70923

Spaces

set/p pass = Please enter your password:
          ^ This space is included in the name of the variable

So, your variable is named %pass %. Change to

set /p "pass= Please enter your password:"

Upvotes: 1

Related Questions