Batch programming, username changing

August 13, 2009 at 11:25:44
Specs: Windows XP
I am putting together a batch file to copy data from one machine to the other. The problem I am facing is that I find that I have to keep changing the username, (i.e. c:\documents and settings\...) everytime I use it with someone new.

Is there some coding I can put in there that can maybe auto-detect the user profile im working with or maybe ask for the user profile name and substitute it with a pre-existing value?

Any and all help is appreciated, thank you much all.

See More: Batch programming, username changing

Report •

August 13, 2009 at 13:19:51
You described almost to a T the description of what it is you need.

What you want to do is use a variable in place of the hardcoded path.

In your case, you'll have one of tow choices.

If you want just the current username to be a part of your path you can use:

C:\Documents and Settings\%Username%

If you want to make sure you're full proof against any anomalies in system drive (as well as the added benefit of typing less ;) ) you can use the %userprofile% variable, which would be equal to the full path (i.e C:\Documents and Settings\JoeUser ) independent of what their system drive letter is.

You can find a full list of variable available here:

Report •
Related Solutions

Ask Question