Environ("username")
Give the windows API a whirl...
Private Declare Function GetUserName Lib "advapi32.dll" Alias _
"GetUserNameA" (ByVal lpBuffer As String, ByRef nSize As Long) As Long
Function GetUser() As String
Dim Ret As Long
Dim UserName As String
Dim Buffer As String * 25
Ret = GetUserName(Buffer, 25)
UserName = Left$(Buffer, InStr(Buffer, Chr(0)) - 1)
GetUser = UserName
End Function
Sub test()
MsgBox GetUser
End Sub
--
HTH...
Jim Thomlinson
"riso" wrote:
Hi folks,
An IT administrator 'created' 10 PC with windows XP with 2 users,
namely "administrator" and "weakuser", with an imagedisc. Later
administrator logged in to every computer and changed the account name
of the user from 'weakuser' to the real name of a person who uses that
computer (e.g. Smith, Shepard, etc).
The interesting thing is that Environ("username") on every PC returns
'weakuser', not the real name. Is it possible to find the login (Smith
or Shepard or etc.) in VBA?
thanks
|