Accessing Current Logged in Users full name

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

redbull8vodka

Thread Starter
Joined
Jun 5, 2007
Messages
5
Hi there,

I am trying to access the current logged in users full name from XP for example, When the user logs in they type jbs10 and the users name is (John B Smith) on the XP login screen. I need to access this information so that I can store the users name in a database. I preferably need to access this information through scripting or VBA etc.

Thanks in advance.

Red.
 
Joined
Aug 23, 2005
Messages
429
Try using this code:

Dim comp
Dim user
Dim wsh
dim shell
Dim name

set wsh = CreateObject("Wscript.Network")
set shell = CreateObject("Wscript.Shell")
comp = wsh.ComputerName
name = "Guest"
set user = GetObject("WinNT://" & comp & "/" & name & ",user")
msgbox(user.get("FullName"))
 

redbull8vodka

Thread Starter
Joined
Jun 5, 2007
Messages
5
Hi thanks for the reply but unfortunately i get the following error.....

"Automation Error
The user name could not be found"

This is generated through the line Set user = GetObject("WinNT://" & comp & "/" & name & ",user") where I have changed the name to my short login code.

Any ideas?

Red
 
Joined
Aug 23, 2005
Messages
429
The 'name' must match the object name in user accounts,including the correct case, see lusrmgr.msc or control userpasswords2.cpl to list the user accounts.
 
Joined
May 15, 2006
Messages
11,849
I have a question. Why do you have to access the full names of people that are logged into a system?

If you were in the IT department for this that you are trying to do this then there should be someone there to train you.
 

redbull8vodka

Thread Starter
Joined
Jun 5, 2007
Messages
5
OZ

I need this to capure the users name rather than id to populate a database following the completion of a CBT package.

Thanks
 
Joined
Aug 23, 2005
Messages
429
If the user name on the system does not exactly match the account name in the computer, it will not find it and produce an error.
Also, the code does not work with Domain accounts.
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Staff online

Members online

Top