5

The original User's Profile directory lives in a directory like C:\Users\username\AppData.

How can I refer to the current user's profile directory when using the Windows command line?

By searching I found out about %UserProfile% that perhaps refer to the current username, but it does not really work. When I tried using it, I received the error "The filename, directory name, or volume label syntax is incorrect".

  • 1
    In what context do you get the error? CD %USERPROFILE% works as expected, as does CD %LOCALAPPDATA% and CD %APPDATA% – stuartd Nov 28 '13 at 13:38
  • Wjen I used C:\Users\%UserProfile%\AppData – super Dec 9 '13 at 19:24
  • Ah. That would be the issue then. C:\Users\%UserProfile%\AppData would expand to "C:\Users\C:\Users\Super\AppData"! "cd %USERPROFILE%\AppData" works as expected. – carveone Dec 11 '13 at 17:57
  • Thanks carveone...hope will be answering my needs further – super Dec 12 '13 at 18:31
4

Run a command shell (start/Run, then "cmd") and type "set". This will list all the environmental variables available. Having said that, USERPROFILE is perfectly valid. There's also APPDATA and LOCALAPPDATA.

(Edit: stuartd has the right answer too - I was sidetracked while editing!)

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.