Working with User Variables in XP

Windows XP also includes a number of variables to help control and define the user environment. The %username% can be used in place of the currently logged on user, because it will be populated with that value automatically. This comes in handy if you were writing a logon script, and wanted to use the same script for multiple users. For example, the command net use g: \\server1\users\%username% could be used to map drive G: to a folder with the same name as the logged on user. This will save the time and effort associated with creating many individual scripts for different users.

Other useful user-related variables include %userprofile% (try issuing the command cd %userprofile% from the command line C:\> prompt), which was discussed earlier, and %userdomain%, which will return the name of the domain of which the current user is a member. For example, at the command line type echo %userdomain%, and the name of the domain (or computer) that validated the user’s logon request will be displayed.

Author: Dan DiNicolo

Dan DiNicolo is a freelance author, consultant, trainer, and the managing editor of He is the author of the CCNA Study Guide found on this site, as well as many books including the PC Magazine titles Windows XP Security Solutions and Windows Vista Security Solutions. Click here to contact Dan.