input from batch file

hello,
I want to create a batch file in which a user would input some info, then I would use their input, and input it to another part of the batch file.
I googled and found something about how you usually have the user input go into a file, then push the info from the file into whatever line you want in the batch file. So far I have

set /p name="Enter your login name: "
%name% > C:\input\loginnames.txt

however, when I run this, it does ask for the name, but the name isn't put into the loginnames.txt
LVL 1
JeffBeallAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

NVITCommented:
Change to.
echo %name% > C:\input\loginnames.txt

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
JeffBeallAuthor Commented:
wow!
as soon as I saw your solution it made sense! I wouldn't have come up with that on my own though. Just not enough experience making these batch files!
Thank you for the help.
0
Bill PrewCommented:
@JeffBeall,

Keep in mind too that you don't need to save the input into a text file to reference it later in the same BAT file.  The variable can also be used elsewhere in the script once it has been set.

~bp
0
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

Lee W, MVPTechnology and Business Process AdvisorCommented:
If you really need the login name, then that's already in an environment variable.

Just use %username% - it's already there - no set /p username=Enter name; JUST echo %username% > loginnames.txt

Also, as written, that will OVERWRITE every time.  If you want to keep a LOG then you want to use >> to append.

If you want to post EXACTLY what you want to accomplish, it's probably easier to do than you're currently planning.
0
JeffBeallAuthor Commented:
ok, I have to slow down on awarding points.
I'm sorry Bill Prew and Lee W. I've already closed the question, so I can't give you points. I'll ask another question explaining exactly what I'm trying to do.
0
Bill PrewCommented:
No worries on points, just want to help you get the best solution to your problem.

Please link the new question to this one and we will automatically be notified when you post it.

~bp
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows Batch

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.