List out Computers in LAN

G

Guest

Hi everyone,

Is it possible to detect every machine in a LAN and retrieve their network
identification names ?

I want to list them in a combo on my form. Thanks for any help.
 
D

Douglas J. Steele

yes, it's somewhere on www.mvps.org/VBNet

Try http://vbnet.mvps.org/code/network/netserverenum.htm

Obligatory warning: Randy's site is aimed at Visual Basic programmers.
Because there are significant differences between the controls available on
VB forms and forms in Access, not all of his examples convert directly to
Access. For instance, this particular example uses the AddItem method for
the listbox, which won't work in Access 2000 or earlier. (I think it works
in Access 2002, but I don't have it installed to check)
 
G

Guest

Thank you Douglas, it seems to do what I want.

Again, reading from it, I got an impression that it returns a list of
"Servers" in the domain, whereas I want a list of "workstations" apart from
the "Servers". I'm just away from my LAN, where I want to test this. Porting
it into VBA is quite a challenge to me, though. If not successful, I'm
thinking of making a VB exe and access it from my Access Menu, which will
suit just the same.

Can I come back here with my test results ? Will you or somebody with the
KnowHow be kind enough to take a look at this post even after it goes into
"Old Topics" list ? Sorry for asking this. Hope I'm not violating any
netiquette :-(
 
D

Douglas J. Steele

Randy says "NetServerEnum returns, dependant on the bit mask specified,
servers and/or machines that are visible on the local domain". Given that
his sample lists "LAPTOP2000" and "WORKSTATION" as being on the network, I
doubt you'll have any problem. You probably want to change the SV_TYPE_ALL
argument to SV_TYPE_WORKSTATION when calling the function.

What version of Access are you using? As I tried to imply, if you're using
Access 2003 (and possibly Access 2002) , you should be able to take that
code and run it in Access without any issue at all. If you're using an older
version of Access, there are a few options available. One, assuming you
don't have too many machines on the network, is to use Value List for the
RowSourceType property, and list the machines, semi-colon delimited, as the
RowSource property. Another is to store the machines in a table, and use a
query against that table as the RowSource. Lastly, there's the standard
call-back function that can be used to populate a list box or combo box. See
http://msdn.microsoft.com/library/e...owSourceTypeFunctionParameters_HV05187987.asp
for details (don't worry that I picked the Access 2003 version: it's the
same for all versions of Access)

Feel free to post back if you have questions.
 
G

Guest

Oh ! Not withstanding my initial apprehensions, it works like a dream. Thanks
a bunch to Randy and thanks a bunch to you, Douglas.

Having tested, I now have a problem on hand with this.

Am using Access 2003, with Win2000 Pro on most machines and WinXp Pro on
some of them. The problem is to update the list: to add the machines joining
the LAN later (booting up later) or to delete from the list those machines
that have shut down. I thought it would be real-time update, but is taking a
lot of time for the code to recognize these things. Can't understand what's
happening here.

Can you please throw light on this ?
 
D

Douglas J. Steele

No, that's not "real time" code: it's a snapshot of what was current when
the code ran. To refresh the list, requery the listbox. You could use the
form's Timer event to requery on a regular basis if you so desire.

The length of time the code takes has a lot to do with the network speed,
how many machines there are on the network, the speed of the machines and so
on.
 
G

Guest

Douglas J. Steele said:
No, that's not "real time" code: it's a snapshot of what was current when
the code ran. To refresh the list, requery the listbox. You could use the
form's Timer event to requery on a regular basis if you so desire.

Sorry for not being clear. Here is what I did :

I ran the code with two machines ON the network. The code returned these two
machines immediately. When I boot up a third machine and after it completely
boots up, I ran the code again. But, only the first two machines are
returned.

I looked at "MyNetworkPlaces-->WorkGroup" from the machine where I ran the
code, it also didn't show the third machine. This third machine shows up
after a delay of about say, 5 to 10 minutes, after which both "
MyNetworkPlaces-->WorkGroup" and the code are recognizing it.

Is it because the Code uses Windows API and the APIs themselves are taking
time to recognize the machines joining and quitting the network ?(My LAN has
12 machines with Windows 2000 Server.)

If I were to use the Timer of the form, I'll have to know what exactly the
code does, or even how Windows itself handles these situations. I mean, if
the windows environ takes about 5-10 min to show up a newly booted machine,
there's no point in trying to requery the list every one minute.

Hope I am clear. Thanks a million for taking me through this.
 
D

Douglas J. Steele

If the machine isn't showing up in your MyNetworkPlaces, that would imply
there's some delay in the operating system. The API code will only work once
the operating system recognizes the new machine. You'd be better off asking
in a newsgroup related to networking, or to Windows 2000 server, to see what
you can do to reduce the time required for recognition.
 
G

Guest

Hi Douglas,

You're right about this stuff related to Networks and Servers etc.

But the fact that I got the most important part working beautifully makes me
feel obligant to thank you and Randy once again. Thank You !
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top