Author Options:

Help with Batch file...generic code? Answered

I noticed that there is a generic code like %windir% for all computers that takes command prompt all the way to the main drive regardless of what it is...my question is, is there a generic code for users? I want one that will go to the Documents and Settings of the person currently logged onto the computer.


This is an easy one to solve. By typing in "set" in your command prompt, you can see all the already set variables.
Among them was "USERPROFILE". This had the value of my user directory.

So, to get to your documents, you would need to type in:


I hope this helps.

. I'd try searching the Microsoft site for something like token expansion. Token may not be the right word.

. I'd start by looking through the Resistry for something like %CurrUserPath% (that's probably not even close, but should get the idea across).

The best I found was %Username% but it says "Access Denied" Otherwise I have no idea what to look for in the registry

. Hmmmm. I dunno. I would guess that %Username% is exactly that and what you are looking for points to the %Username% directory inside Documents and Settings. . Just guessing, but you may need to run the batch file with that user's privileges (or admin). . If that doesn't work, I'm out of ideas.

I have administrator privileges on my computer and it doesnt work...hmmm I guess I can wait for someone else to add their input

. Oh, MRU (Most Recently Used) entries will probably contain the token you are looking for.