M HYPE SPLASH
// news

How to generically refer to the AppData folder on the Windows command line?

By Abigail Rogers

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

4

2 Answers

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!)

0

Here are some of the common system path variables on windows, but check here for a complete reference:

| Variable | Default Value |
|----------------|------------------------------------------------------------------------------|
| %SystemDrive% | C: |
| %ProgramFiles% | C:\Program Files |
| %AppData% | C:\Users\{username}\AppData\Roaming |
| %LocalAppData% | C:\Users\{username}\AppData\Local |
| %UserProfile% | C:\Users\{username} |
| %UserName% | {username} |
| %COMPUTERNAME% | {computername} |
| %PATH% | C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;{plus program paths} |

These should automatically be expanded when using the windows cmd prompt (or bash / powershell):

cd %UserProfile%

Your specific issue here seems to be using UserProfile instead of UserName. Either use cd %UserProfile% or cd C:\Users\%UserName%

Further Reading:

1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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