There is always WMI but that can be slow.

I have used net view and if there is a return.

All methods are going to have a "timeout" feature of some sort you just need to find the one that responds in what you deem a reasonable time.
_________________________
Today is the tomorrow you worried about yesterday.