How2 pull in Windows Domain & Username

R

Ronio

I would like to pull in the current Domain Name and Username for the logged
in user.
By what means do I access this via VBA?

I've tried "Application.Username", but found it can be inaccurate if the
users has decided to modify the Tools...Options...General to be their
nickname.

~Ron
 
R

Ronio

Thanks Al.

If anybody is interested. Here is the code I used from technet.

strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Set colProcessList = objWMIService.ExecQuery _
("Select * from Win32_Process Where Name = 'VISIO.EXE'")

For Each objProcess in colProcessList
objProcess.GetOwner strUserName, strUserDomain
Wscript.Echo "Process " & objProcess.Name & " is owned by " _
& strUserDomain & "\" & strUserName & "."
Next
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top