Whoami

Good Day, I'm looking for VB code that will deliver the UserID/UserName as "\whoami" will do from a command prompt. Any help is appreciated.
LVL 11
EMCITAsked:
Who is Participating?
 
als315Connect With a Mentor Commented:
VBA. Next time, please, add MS Access database to topics.
You can use:
msgbox environ$("username")

In vb.net it will be:
Environment.UserName
0
 
als315Commented:
Like:
Dim obj as object
Set obj = wscript.CreateObject("wscript.network")
MsgBox obj.Username
You can find also otren methods here:
http://www.robvanderwoude.com/vbstech_network_names_user.php
0
 
EMCITAuthor Commented:
Thanks for the quick response. I get:

Run Time Error 424
Object Required

Dim obj As Object
Set obj = wscript.CreateObject("wscript.network")   *This line is highlighted
MsgBox obj.UserName
0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

 
als315Commented:
What VB is used?
0
 
EMCITAuthor Commented:
VB 6.5 within MS Access 2003
0
 
als315Commented:
You can use also almost same code as in my first comment:
Dim obj As Object
Set obj = CreateObject("wscript.network")
MsgBox obj.UserName
0
 
EMCITAuthor Commented:
Thanks so much. Sorry for the confusion.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.