COMMUNITY : FORUMS : SQUARE PEGS


Help with Batch file...generic code?

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.

sort by: active | newest | oldest
Prof. Pickle says: Dec 14, 2012. 7:24 PM
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:

CD %USERPROFILE%/Documents

I hope this helps.

NachoMahma says: Jun 19, 2007. 2:31 AM
. I'd try searching the Microsoft site for something like token expansion. Token may not be the right word.
NachoMahma says: Jun 18, 2007. 12:30 AM
. I'd start by looking through the Resistry for something like %CurrUserPath% (that's probably not even close, but should get the idea across).
Serneum (author) says: Jun 18, 2007. 11:47 AM
The best I found was %Username% but it says "Access Denied" Otherwise I have no idea what to look for in the registry
NachoMahma says: Jun 18, 2007. 4:39 PM
. 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.
Serneum (author) says: Jun 18, 2007. 5:18 PM
I have administrator privileges on my computer and it doesnt work...hmmm I guess I can wait for someone else to add their input
NachoMahma says: Jun 18, 2007. 12:32 AM
. Oh, MRU (Most Recently Used) entries will probably contain the token you are looking for.
Pro

Get More Out of Instructables

Already have an Account?

close

PDF Downloads
As a Pro member, you will gain access to download any Instructable in the PDF format. You also have the ability to customize your PDF download.

Upgrade to Pro today!