Solved

Domain Name

Posted on 2001-06-25
1
127 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
1 Comment
 
LVL 27

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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

Suggested Solutions

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

777 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