• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 507
  • Last Modified:

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.
0
EMCIT
Asked:
EMCIT
  • 4
  • 3
1 Solution
 
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
 
als315Commented:
What VB is used?
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
EMCITAuthor Commented:
VB 6.5 within MS Access 2003
0
 
als315Commented:
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:
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

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now