' Returns the domain name
' Requires a reference to System.Management and the respective Imports
Function GetDomainName() As String
Dim mos As New ManagementObjectSearcher _
("SELECT * FROM Win32_ComputerSystem")
Dim mo As ManagementObject
For Each mo In mos.Get()
Return mo("Domain")
Next
End Function