I've seen that you can use %USERNAME% to get the whole path but I just want to get e.g John Doe for use in mapping a network drive to specific folders named after the user profile names?
e.g
NET USE h: \test\Citrixusers\%USERNAME%
but of course this gets the username as C:\Users\"Name"
So the end result would be like \test\Citrixusers\John Doe
Thanks in advance all.
Best Answer
How do you get the User Profile name in a batch file?
It appears you are confusing
%USERNAME%
and%USERPROFILE%
.%USERNAME%
contains just the username.%USERPROFILE%
contains the profile path (which includes the username).Standard (built-in) Environment Variables
...
Source environment variables - Environment variables are mainly used within batch files, they can be created, modified and deleted for a session using the SET command.
Further Reading