Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get path to the user home directory on Windows in PowerShell? [duplicate]

I am trying to get the path to the current user's home directory (e.g. C:\Users\User1) while respecting different localizations of Windows (which have a different name for the Users folder).

I have seen solutions in Batch, but isn't there a clean way of doing it in PowerShell?

like image 984
Nikita Karamov Avatar asked Sep 12 '25 12:09

Nikita Karamov


1 Answers

Use the environment variable $env:USERPROFILE.

For example:

cd "$env:USERPROFILE\Downloads"

will take you to the user's Downloads folder (given that it's named "Downloads").]

like image 170
Nikita Karamov Avatar answered Sep 15 '25 12:09

Nikita Karamov