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

Domain Name

Hi,
Can anybody help me in retrieving the username and the DOMAIN of the user on a Win95 Environment.

Thanx
Harish
0
harishsc
Asked:
harishsc
1 Solution
 
ArkCommented:
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!

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