tags:

views:

44

answers:

3

For practical purposes, what SqlDataSourceEnumerator does is find all instances of SQL server running on the various PCs on a LAN.

Is there an equivalent for finding running instances of an arbitrary application?

Edit: OK, so this only works because these apps have a pre-defined method of cooperation. Is there a straightforward way of determining if a given file (the exe, say) exists on some machine on the LAN even if the app itself itself is not running at the time? Understood that permissions must be taken into account.

A: 

The difference is that SqlDataSourceEnumerator finds all instances "that it can see" on a LAN. If the server process is configured not to respond to that request, then it won't be seen.

Along that same line, you can scan for any application that has some way of making its presence known remotely. At its simplest, the application would be listening for and responding to connections. The application could, for example, bind to a TCP port and listen for any request and send back a response saying that it's alive and running, and hosts on a network can be scanned for those replies.

As for "an arbitrary application" however, most applications don't have such a mechanism for network discovery. If you control the arbitrary application then you can build that functionality into it. But if you do not then you'll need some way to look for that application on any given host, which means it'll need some kind of network interaction.

David
A: 

What SQL enumeration does it broadcasts an UDP packet (port 1434) on the entire lan segment (subnet mask). The SQL Browser Agent service running on various hosts listens for this packet and responds with the list of local instances. So for the enumeration to happens, a number of ducks are already aligned for you:

  • there is a well know protocol for SQL isntance discovery, the UDP 1434 broadcast and response
  • there is a service listening for this broadcast, installed by SQL Server setup
  • there is a client library to implement the broadcast request formatting and response parsing which you leverage

For an arbitrary application to behave the same, the said application would have to implement these missing parts. Discovering arbitrary processes running on arbitrary hosts in a subnet segment is basically impossible for all practical means.

Remus Rusanu
A: 

No, there isn't.

The reason that works for SQL server is that SQL server has a listener that listens on the network for "discovery" requests. An app can then send out a broadcast message on the network and listen for responses to that request to discover SQL server instances.

I suppose you could write a program that would do this generically though - It could listen for discovery requests, use some windows API functions to enumerate the processes running on that computer, and respond if the requested program is running.

Eric Petroelje