Reputation: 508
I'm making some installation systems, and I want it to find the current user, and go to the user's folder. So for example, if the current user is Joe, then I want it to change the directory to Joe's folder instead of Mary's.
Upvotes: 2
Views: 884
Reputation: 3736
I would say that depends totally on the System you use:
For the Username:
echo %username%
echo "$USER"
System.getProperty("user.name")
For the User-Home-Directory:
echo %userprofile%
echo "$HOME"
System.getProperty("user.home")
(echo
is just the command to print something)
Upvotes: 0
Reputation: 14305
The %username%
system variable contains the current user name.
You can also use %userprofile%
as a substitute for C:\Users\<user>
Upvotes: 1