Link to home
Start Free TrialLog in
Avatar of crescendo
crescendo

asked on

A fast way to tell if a remote PC is on?

I'm writing a utility to scan lots of systems. Before I try to read their registry and disk drives I need to know whether they are 'on' or 'off'. I've used the www.allapi.net API routines to send a PING, but it still takes 4 - 6 seconds to return if the PC is off, and with a lot of machines that can soak up a lot of time.

In the NT4 Server Manager program, it displays a list of servers and workstations very quickly, with 'unavailable' systems greyed out. How does it do this? Is there an API that returns a system's online status?
Avatar of R_Rajesh
R_Rajesh

Hi crescendo,

not very elegant, but you could create a mapped drive to each of those system, then check for the existance of a file in that drive. say you mapped system2's C drive to V: of you system then

if dir("v:\test.txt") = "" then its off else its on


Cheers!

Raj
ASKER CERTIFIED SOLUTION
Avatar of g0rath
g0rath

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
Yup, I use the ICMP ping you linked him too.  It works great.  500ms (1/2 second) timeout tells you the pc isn't there.  

You should find it works well for you, also.  I use this particular method on an application that checks 1200 workstations to ensure virus definitions are up to date.  Even with the other things I do, it scans 1200 machines and what's on and what's not and updates any out of date definitions in about 10 minutes flat.  So it's pretty quick.

1/2 second beats 4 to 6 seconds hands down . . .

Just a question though, what call are you using to get your list of workstations?  Depending on the method you may be getting names that aren't in use, and that would slow it down as you try to resolve the hostname to an IP.
Listening
Avatar of crescendo

ASKER

Hi all

Sorry for the delay in replying, been off site.

I'll try the ping utility, 500mS would be fine.

I get the list of machines in the domain through ADSI, and yes, it includes systems that don't exist but still have machine accounts. I've just been experimenting with the NetServerEnum (I think that was the right name) API and it's much faster and only seems to list machines that are online at the moment. I believe it gets the list from the master browser, which explains how it knows who is 'on' at the time. I think that if I combine this API with the results from ADSI and the fast ping, I should have a solution. (I still need the ADSI list so that I can see who didn't get updated because the machine was unavailable at the time, and need to ping in case the machine goes off after I get the list).

I'll let you know how I get on.

Thanks folks
Have a look for some "hacker" tools. Looking for machines that are "up" is a basic requirement for hackers, and there are many "port scanner" available for free download that are highly optimised for gathering a lot of information in a short time.