How do you get the User Profile name in a batch file?
without the complete path
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
Variable Default value in Windows 7/2008
...
USERNAME
USERPROFILE %SystemDrive%\Users\
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
- An A-Z Index of the Windows CMD command line - An excellent reference for all things Windows cmd line related.