Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Getting the 'username' environment variable from vbscript

399 views
Skip to first unread message

Mike Varley

unread,
Jul 16, 2002, 9:36:20 AM7/16/02
to
From within a web page we want to run something similar to:

Set WshShell = WScript.CreateObject("WScript.Shell")
Set WshSysEnv = WshShell.Environment("SYSTEM")
WScript.Echo WshSysEnv("NUMBER_OF_PROCESSORS")

This works ok. We however want to get at the environment variable
'USERNAME'. We have tried things like:

Set WshShell = WScript.CreateObject("WScript.Shell")
Set WshSysEnv = WshShell.Environment("PROCESS")
WScript.Echo WshSysEnv("USERNAME")

and

Set WshShell = WScript.CreateObject("WScript.Shell")
Set WshSysEnv = WshShell.Environment("USER")
WScript.Echo WshSysEnv("USERNAME")

but we just get a blank for the username. Other environment variables work
OK.

Any ideas?

Cheers

Mike

Mike McGuire

unread,
Jul 16, 2002, 9:48:45 AM7/16/02
to
Not sure if this is what you're looking for, but it will give you the
username of the person logged in:

Set WshNet = CreateObject("WScript.Network")
WScript.Echo WshNet.username

Mike

"Mike Varley" <mi...@nacstock.ac.uk> wrote in message
news:enRgk2MLCHA.1624@tkmsftngp10...

Lee Derbyshire

unread,
Jul 16, 2002, 10:06:15 AM7/16/02
to

How about Request.ServerVariables("REMOTE_USER") if you're using
authentication.

Lee.

--
___________________________________

Outlook Web Access for PDA and WAP:
www.leederbyshire.com
___________________________________

"Mike Varley" <mi...@nacstock.ac.uk> wrote in message
news:enRgk2MLCHA.1624@tkmsftngp10...

Michael Harris (MVP)

unread,
Jul 16, 2002, 4:25:35 PM7/16/02
to
IIRC the USERNAME environment variable only exists on NT-based system (NT4/Win2K/WinXP)...

set net = createObject("wscript.network")
msgbox net.username

You're better off following Lee's advice - use authentication and get the info server side rather than using unsafe ActiveX components on the client...

--
Michael Harris
Microsoft.MVP.Scripting
Seattle WA US
--


0 new messages