Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to get work group name of my system. I dont want retrieve system name I need WorkGroup name
Example my system name is Computer1. My work group name is Computer Tech. I want to retrieve the name Computer Tech


Thanks in advance
Posted

1 solution

Try this:
http://msdn.microsoft.com/en-us/library/system.environment.userdomainname.aspx[^]
http://stackoverflow.com/questions/2719362/how-can-i-get-the-domainname-accountname-with-the-net-framework[^]
http://stackoverflow.com/questions/1799068/getting-a-list-of-users-on-a-network-domain[^]
http://code.msdn.microsoft.com/windowsapps/User-domain-name-sample-85ce3e49[^]

[EDIT #1]
http://www.vbforums.com/showthread.php?242441-get-and-set-Workgroup-name-RESOLVED[^]

VB
Dim mos As System.Management.ManagementObjectSearcher
Dim moc As System.Management.ManagementObjectCollection
Dim mo As System.Management.ManagementObject
Dim prop As System.Management.PropertyData = Nothing
Dim FSO As Object = Nothing
Dim txtstream As Object = Nothing
Dim MyString As String = String.Empty
mos = New System.Management.ManagementObjectSearcher("SELECT * FROM Win32_NetworkAdapterConfiguration")
moc = mos.Get()
For Each mo In moc
    Console.WriteLine(mo.GetText(Management.TextFormat.Mof))
Next



Above code returns information about Win32_NetworkAdapterConfiguration. Look for DNSDomain.
 
Share this answer
 
v2
Comments
Usha Muhunthan 8-Apr-13 6:37am    
All the links return only the computer name Computer1 not WorkGroup Name Computer Tech
Maciej Los 8-Apr-13 8:19am    
See updated answer.
Usha Muhunthan 8-Apr-13 8:31am    
Its shows 5 errors those all about Type not defined
1. System.Management.ManagementObjectSearcher
2. System.Management.ManagementObjectCollection
3. System.Management.ManagementObject
4. System.Management.PropertyData = Nothing
5. System.Management.ManagementObjectSearcher


Sholud i use any Imports or anything else
Maciej Los 8-Apr-13 8:38am    
Just add a reference to System.Managment namespace.
How? http://msdn.microsoft.com/en-us/library/vstudio/wkze6zky%28v=vs.80%29.aspx[^]

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900