Re: VBSCRIPT to get USERNAME / LOGIN

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



On Feb 22, 10:15 am, "colo" <mario.color...@xxxxxxxxx> wrote:
Hi!

I am new to VBSCRIPT and can't find a way to get the username of the
person looking at the webpage. I'm working inside the intranet, so
everyone is already logged in. From an ASP page I am sending a email
when the user clicks on submit... what I need to do is include the
username (login name) of the person sending the form. How can I do
this?

Thanks a lot for your help!!!

This may help you out since you say this is on your Intranet.

Set WSHShell = CreateObject("WScript.Shell")
Set WSHNetwork = CreateObject("WScript.Network")
'Automatically find the domain name
Set objDomain = getObject("LDAP://rootDse";)
DomainString = objDomain.Get("dnsHostName")
WinDir = WshShell.ExpandEnvironmentStrings("%WinDir%")

'Grab the user name
UserString = WSHNetwork.UserName
'Bind to the user object to get user name and check
'for group memberships later
Set UserObj = GetObject("WinNT://" & DomainString & "/" & UserString)

'Grab the computer name for use in add-on code later
strComputer = WSHNetwork.ComputerName


Hope this helps
John Fuhrman

.



Relevant Pages