c# - Checking status of remote services -
this method used obtain status of services on remote server:
private getservicestatus(tmsg, exceptioncollection, input) { nsdatatypes.getservicestatusoutput output = new nsdatatypes.getservicestatusoutput(); try { nssemlib.servicecontrollerex[] svcs = new nssemlib.servicecontrollerex[] { new nssemlib.servicecontrollerex(input.servicename, input.servername) }; nssemlib.servicecontrollerex svc = svcs[0]; system.serviceprocess.servicecontrollerstatus s = svc.status; switch (s) { case system.serviceprocess.servicecontrollerstatus.running: output.servicestatus = nsdatatypes.servicestatus.started; break; case system.serviceprocess.servicecontrollerstatus.stopped: output.servicestatus = nsdatatypes.servicestatus.stopped; break; case system.serviceprocess.servicecontrollerstatus.paused: output.servicestatus = nsdatatypes.servicestatus.paused; break; default: output.servicestatus = nsdatatypes.servicestatus.notexists; break; } try { nssemlib.servicecontrollerex.servicestartmode startmode = svc.startuptype; switch (startmode) { case nssemlib.servicecontrollerex.servicestartmode.automatic: output.servicestartmode = nsdatatypes.servicestartmode.automatic; break; case nssemlib.servicecontrollerex.servicestartmode.manual: output.servicestartmode = nsdatatypes.servicestartmode.manual; break; case nssemlib.servicecontrollerex.servicestartmode.disabled: output.servicestartmode = nsdatatypes.servicestartmode.disabled; break; case nssemlib.servicecontrollerex.servicestartmode.default: output.servicestartmode = nsdatatypes.servicestartmode.default; break; default: output.servicestartmode = nsdatatypes.servicestartmode.default; break; } } catch (exception ex) { } } catch (exception ex) { output.servicestatus = nsdatatypes.servicestatus.notexists; ex = null; } return output; }
during debugging when code gets point:
system.serviceprocess.servicecontrollerstatus s = svc.status;
i getting error:
ex = {"service ngarchivalep_002 not found on computer 'servername'."}
however if check server can see service exists in stopped status. instead of generating error app should have read service stopped , depicted on webpage. think related recent id change released how find out id web app using connect these remote servers? id defined in app pool?
Comments
Post a Comment