232Views7Replies

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.

Comments

The forums are retiring in 2021 and are now closed for new topics and comments.
0
Prof. Pickle
Prof. Pickle

8 years ago

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.

0
NachoMahma
NachoMahma

13 years ago

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

0
NachoMahma
NachoMahma

13 years ago

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

0
Serneum
Serneum

Reply 13 years ago

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

0
NachoMahma
NachoMahma

Reply 13 years ago

. 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.

0
Serneum
Serneum

Reply 13 years ago

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

0
NachoMahma
NachoMahma

Reply 13 years ago

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