Link to home
Start Free TrialLog in
Avatar of DubbleEagle
DubbleEagle

asked on

Get workgroup name(s) in LAN

I have been searching the internet for 2 days now, and I can't find any good line(s) of code about how to retrieve the workgroup name I am connected to. Or even better: getting all workgroups within the local network (LAN). I am using Windows XP (Home edition) but it would be nice if it works for all versions of windows.

Code should be in VB.Net !

Thanks
Avatar of RonaldBiemans
RonaldBiemans

Avatar of DubbleEagle

ASKER

Ronald, I have seen this topic before, and I got some problems testing it. If I insert the code in VB.Net, I get some errors, including the line

Dim wshShell As New IWshShell_Class

which is (in my opinion) part of the code for retrieving a registry value. IWshShell_Class is not known by my compiler (maybe I should add a reference?).

Also, if I check my registry (via regedit), I cannot find the subdirectory "VDX" in HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\

Maybe usefull information (?): I am using Visual Studio .Net 2003 Professional
Imports System
Imports System.Security

Private Function GetUserName() As String
        Return Principal.WindowsIdentity.GetCurrent.Name()
        ' This will return 'domain(or workgroup)\username' so just parse the Info
    End Function
I tried the code you suggested (with msgbox() instead of return), but it gives me the following information:

"Computername/CurrentUserName"

The name of the workgroup is not listed  :(
I'll try out that topic, and will let you know if it worked  :-)
Ok, I tried everything listed there. Good thing is: I don't need the workgroup name to get all workstations/servers from the network. Bad thing is, that I still can't get the name of the workgroup I'm connected to.

I would like to create a tree-structure of all workgroups, with all computers connected to them (like windows-explorer: my-network-connections, microsoft-windows-network  -  from there, you get a tree view of the entire network)

If that shouldn't be possible, at least I would like to retrieve the name of my workgroup
ASKER CERTIFIED SOLUTION
Avatar of graye
graye
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thnx, this works perfect!