JSI Tip 5458. How do I retrieve the user's full name in a logon script?

Jerold Schulman

June 19, 2002

1 Min Read
ITPro Today logo in a gray background | ITPro Today


If you require the users full name in a domain logon script, include the following command in your script:

for /f "Tokens=2*" %%m in ('net user %USERNAME% /domain ^| find "Full Name"' ) do set fname=%%n

The users full name will be set into the fname environment variable.

To use the fname environment variable, see the following example:

@echo Welcome %fname%.

If you require the users full name in a local logon script, include the following command:

for /f "Tokens=2*" %%m in ('net user %USERNAME% ^| find "Full Name"' ) do set fname=%%n



Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like