using System.Management;
static bool ServiceIsRunning(string ServiceName)
{
ConnectionOptions op = new ConnectionOptions();
op.Username = "domain\\username";
op.Password = "password";
ManagementScope scope = new ManagementScope("\\\\OLAP1\\root\\cimv2", op);
scope.Connect();
string objPath = string.Format("Win32_Service.Name='{0}'", "SubscribeReportService");
using (ManagementObject service = new ManagementObject(scope, new ManagementPath(objPath), null))
{
if (service.GetPropertyValue("State").ToString() == "Running")
return true;
else
return false;
}
}
http://stackoverflow.com/questions/1335065/check-status-of-services-that-run-in-a-remote-computer-using-c-sharp
No comments:
Post a Comment
Note: only a member of this blog may post a comment.