¤ The problem is that I cannot use these 2 examples on a
¤ Windows98/WindowsME machine.
¤
¤ Is there any other way I can get the Workgroup/Domain name
¤
How about the following:
Environment.UserDomainName()
Paul ~~~ (e-mail address removed)
Microsoft MVP (Visual Basic)
It took me a while to get the hang of the WMI stuff - and I still can't get
"complex" queries to work properly. See how you get on with this example;
Dim vQuery As New ManagementObjectSearcher("SELECT * FROM
Win32_ComputerSystem")
For Each vComputer As ManagementObject In vQuery.Get ' In case there's more
than one computer )
' List all properties of Win32_ComputerSystem
For Each vProperty As PropertyData In vComputer.Properties
Console.WriteLine(vProperty.Name)
Next
' Print a random property
Console.WriteLine("Domain is: " & vComputer("Domain").ToString)
Next
________________________
The Grim Reaper
¤ The problem with this function is that it returns the domain name that
¤ the user logged onto.
¤
¤ Scenario
¤
¤ Computer is registered in DomainA
¤ User is registered in DomainB
¤
¤ I want the DomainA name but I get DomainB as the domain name when I use
¤ System.Environment.UserDomainName.
¤
¤ It is important that I get DomainA
I can't test this in a multiple domain environment but see if the following works for you:
Dim WMIComputerSystem As New System.Management.ManagementObjectSearcher("select * from
Win32_ComputerSystem")
Dim WMIInfo As System.Management.ManagementObject
For Each WMIInfo In WMIComputerSystem.Get
Console.WriteLine(WMIInfo("Domain").ToString)
Next WMIInfo
Paul ~~~ (e-mail address removed)
Microsoft MVP (Visual Basic)