getting current user's name

I need to run a file from the command line. The file is located in desktop folder:

How can I automatically get current user's name and place it in the line above (instead of 'username')?
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.


I am not sure what you want a 100%, but to get the user name from a command prompt you can use the variable %USERNAME% to try this open a command window and type "echo %username%" without quotes.

If you want the profile you would use %userprofile% test same as above with echo command.

Let me know if you need more help!

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
Steve KnightIT ConsultancyCommented:
You have your answer anyway... but to add a way to see all these, open a cmd.exe prompt and type the word SET and press return.  You will see all the variables, e.g.

For instance a desktop entry for all users on a Windows 7 PC would be in %public%\desktop

Lee W, MVPTechnology and Business Process AdvisorCommented:
Actually, while %username% DOES grant the user name, if you are trying to access the user's profile, you should be using the %userprofile% environment variable, not %username% - in case the profile location has changed or runs on Windows XP (which you should be getting rid of).
Steve KnightIT ConsultancyCommented:
Lee, ebad-it said that already which is why I didn't elaborate.

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.