Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

User ID 1

Status
Not open for further replies.

PhilBreau

Technical User
Dec 14, 2001
108
CA
Is there a script command which can read the PC's user ID? In DOS there is a command Net Config whill will report some
information.

Output sample:

C:\WINDOWS\DESKTOP>net config
Computer name \\WCABBLR0230
User name PBREAU
Workgroup Company
Workstation root directory C:\WINDOWS

Software version 4.00.950
Redirector version 4.00
The command was completed successfully.

I would like to extract the the username. Is there something a script command can do?
 
Go to a DOS prompt, type set, and press the Enter key. On my NT machine, there is an environment variable called USERNAME that had this information. Here's a script that would retrieve that environment variable:

proc main
string sUserName

getenv "USERNAME" sUserName
usermsg "%s" sUserName
endproc

I seem to recall some discussion on this a year or so ago, and I'm not certain if Win9x had this variable defined. If not, you could use this line in your script:

dos "net config > c:\username.txt"

to save the output from net config to a text file, then open the file, read line by line until you find the line:

User name PBREAU

(you could use the strfind command to search for "User name"), then extract the username from that string.


aspect@aspectscripting.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top