3

I have a problem in getting a list of computers in my workgroup from my windows 8 (x64) system.

In my workgroup there are several computers: some with W7 and some with W8. The W7 computers are able to get a list of all workgroup PCs whereas the W8 computers can not (no result, not even the PC running the code) with the same code.

using (DirectoryEntry workgroup = new DirectoryEntry("WinNT://Workgroup"))
    {
        foreach (DirectoryEntry childEntry in workgroup.Children)
        {
            Console.WriteLine(childEntry.Name);
        }
    }

i was trying the solutions given here: Get computers in a workgroup

does anyone have an idea about this?

update: Visual Studio is run as Administrator for this

Community
  • 1
  • 1
Mikk
  • 331
  • 4
  • 13
  • I assume that you can see the workgroup machines through Explorer right? – Simon_Weaver Jan 27 '13 at 20:50
  • yes there everything is showing (every computer in the WG can see the others) – Mikk Jan 27 '13 at 20:53
  • another observation .. commandline "net view" will return in an error 53 .. so it seems that i have some other problem on the computers which are not related to .NET – Mikk Jan 28 '13 at 20:50

1 Answers1

2

Run your Visual Studio or the executable produced by it as administrator.

If the case is that you are already running the VS/exe as administrator then make sure that the W8 machines are in the same workgroup called "WORKGROUP" and that they are not Windows RT (Windows on ARM) OS-es because those do not support workgroups.

Konstantin Dinev
  • 34,219
  • 14
  • 75
  • 100
  • What if you aren't running the program through the debugger, as in outside of Visual Studio? – Austin Henley Jan 27 '13 at 20:22
  • @AustinHenley Then the executable needs to be ran as administrator. – Konstantin Dinev Jan 27 '13 at 20:23
  • sorry, i forgot to add that to the question: VS was running with administrator rights .. just tried it with the compiled program outside VS aswell .. makes no difference. only returned result is "Schema" (which would be ignored in the normal program later) – Mikk Jan 27 '13 at 20:26
  • @Uwe Is your workgroup for the W8 machines called "WORKGROUP"? Also are they Windows RT machines because those do not have a workgroup – Konstantin Dinev Jan 27 '13 at 20:31
  • yes its just the default name "WORKGROUP". There are no RT machines. All are running W8 professional x64. Maybe its nothing with the code but some windows settings .. maybe someone can try/confirm if the code works on his machine/network. – Mikk Jan 27 '13 at 20:34
  • @Uwe Unfortunately I'm at my home computer and I don't have a visual studio on this one so I cannot try the code :( – Konstantin Dinev Jan 27 '13 at 20:37
  • thats fine really .. maybe someone else will be able to give a hint. but thanks a lot for your help! – Mikk Jan 27 '13 at 20:38
  • I have also run in to an issue where one domain returns all objects, yet the same code, running with the same permissions, against another domain, only returns one result, "Schema". Did you ever get to the bottom of this? – Sam Makin Nov 25 '14 at 16:54