c# check remote computer is online
// using System.Management;
private static bool IsMachineOnline(string hostName)
{
bool retVal = false;
ManagementScope scope = new ManagementScope(string.Format(@"{0}rootcimv2", hostName));
ManagementClass os = new ManagementClass(scope, new ManagementPath("Win32_OperatingSystem"), null);
try
{
ManagementObjectCollection instances = os.GetInstances();
retVal = true;
}
catch (Exception ex)
{
retVal = false;
Console.WriteLine(ex.Message);
}
return retVal;
}