Addressing the user

March 12, 2010 at 07:59:55
Specs: Windows XP
i want to know if there is a way to have your batch file address the user. E.x. have the file prompt the user to type his/her name in then have the file say something along the lines of hello ~insert name here~.

-Jordan


See More: Addressing the user

Report •

#1
March 12, 2010 at 09:37:46
I replied to you in PM
But. I'll answer this. Because there are some different things you can do.

First is getting user input.
Set /p Name=Type your name:
They enter name...

Then you put the code
Echo Hello %Name%.

If the person types "Matt"
The 2nd line of code will say
Hello Matt.

You can also use this variable
%username%
This will display the user that you are logged into.
So if your username is "Matt".
%username% will be replaced with the username you're logged into.

Here's some Examples of Code.

@ECHO OFF
Echo.
Echo Type your name.
Echo.
Set /p Name=Type:
CLS
Echo.
Echo Welcome %Name%! How are you ?
Pause >nul

And also try this one.
@ECHO OFF
Echo.
Echo Hello %username%.
Echo.
Pause >nul

Hope that helps!

******************************************
MSN = HardstyleMatt@hotmail.co.uk
Need help? Just ask. :)
******************************************


Report •
Related Solutions


Ask Question