When you type username /?, you receive:

UserName V01.00.00cpp Joe Richards ( October 2002                              Usage:                               UserName \[switches\]                                Switches: (designated by - or /)                                 -t text    Text to write in front of value (not valid with -f).                                 -f file    Writes a file with cmd/bat file format with major formats.                                    Variables possibly defined                                     UN-DN           Fully Qualified DN                                     UN-SAM          SAM Name                                     UN-Display      Display Name                                     UN-UniqueID     Unique ID                                     UN-Canonical    Canonical Name                                     UN-UPN          User Principal Name                                 -format x  Format to write value in:                                     1               Fully Qualified DN                                     2               SAM Name                                     3               Display Name                                     6               Unique ID                                     7               Canonical Name                                     8               User Principal Name                                     9               Canonical Name Extended (2 line output)                                     10              Service Principal Name                                Note:                                  Write the output to a cmd or bat file and then CALL the file and it                                  will load the environment variables into the environment namespace.                                Ex1:                                  username                                    Displays current user's SAM Account Name                                Ex2:                                  username -format 1                                    Displays current user's Full Qualified DN                                Ex3:                                  username -format 1 -t "set u="                                    Displays current user's FQ DN as set u=                                Ex4:                                  username -f vars.cmd                                    Dumps all values it can to vars.cmd in set xxx= format                               This software is Freeware. Use it as you wish at your own risk.                               If you have improvement ideas, bugs, or just wish to say Hi, I                               receive email 24x7 and read it in a semi-regular timeframe.                               You can usually find me at