?
Solved

Domain Name

Posted on 2001-06-25
1
Medium Priority
?
131 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 150 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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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 process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

771 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