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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

reading user id from user environment/registry

Status
Not open for further replies.

zzzqqq

Programmer
Oct 12, 2005
17
IE
Hi,
Anyone know how to read a user id from the user environment/registry in VBScript. I'm new to VBScript and using IIS Server and asp pages. Is there a variable for this?
Thanks
 
Code:
Set objWSHNetwork = CreateObject("WScript.Network")
UserString = objWSHNetwork.UserName
msg = "The current username is " & UserString
Msgbox msg

JJ
[small][purple]Variables won't. Constants aren't[/purple][/small]
 
Sorry,
This seems to get me the asset number, I'm looking for getting the user id if logged onto the system, e.g. User Name = 23543. Is this possible?
Thanks.
 
Not sure what to say to that. The code I've given you works for me (in more than one script I have).

Let's try another (less tidy) way...

Code:
Set objWSHShell = WScript.CreateObject("WScript.shell")

strUserName = objWshShell.ExpandEnvironmentStrings("%USERDOMAIN%") &_
    "\" & objWshShell.ExpandEnvironmentStrings("%USERNAME%")

msg = "The current username is " & strUserName

Msgbox msg

JJ
[small][purple]Variables won't. Constants aren't[/purple][/small]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top