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

♀尐吖头ヾ 提交于 2020-01-17 04:56:08

问题


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:"


回答1:


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:"


来源:https://stackoverflow.com/questions/26022484/inputting-a-variable-into-a-text-file-using-a-batch-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!