Solved

Domain Name

Posted on 2001-06-25
1
129 Views
Last Modified: 2010-05-02
Hi,
Can anybody help me in retrieving the username and the DOMAIN of the user on a Win95 Environment.

Thanx
Harish
0
Comment
Question by:harishsc
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 28

Accepted Solution

by:
Ark earned 50 total points
ID: 6225716
Hi
You can do it with Windows Scripting Host. Unfortunatelly, WSH under w95 don't show UserDomain (see http://support.microsoft.com/support/kb/articles/Q188/6/02.asp).

So, code:

Private Sub Command1_Click()
  Dim oNetwork As Object
  Dim oShell As Object
  Dim sDomain As String, sUserName As String, sCompName As String
  Const LogDomstr = "HKLM\SYSTEM\CurrentControlSet\Services\MSNP32\NetworkProvider\AuthenticatingAgent"
  Const Workgroupstr = "HKLM\SYSTEM\CurrentControlSet\Services\VxD\VNETSUP\Workgroup"
  Set oNetwork = CreateObject("WScript.Network")
  Set oShell = CreateObject("WScript.Shell")
  sUserName = oNetwork.UserName
  sCompName = oNetwork.ComputerName
  sDomain = oShell.RegRead(LogDomstr)
  If (sDomain = "") Then sDomain = oShell.RegRead(Workgroupstr)
  Debug.Print sUserName, sDomain, sCompName
  Set oShell = Nothing
  Set oNetwork = Nothing
End Sub

Cheers
0

Featured Post

Industry Leaders: 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!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question