public string IsStartDispatchHander(out string statusCode, out string errMsg) { statusCode = "0000"; errMsg = ""; if (!ServiceToolEx.IsServiceExist(dispatchServerName)) { errMsg = dispatchServerName + "服务不存在"; statusCode = "4004"; return(""); } string curFilePath = ServiceToolEx.GetWindowsServiceInstallPath(dispatchServerName); if (curFilePath.ToUpper() != new DirectoryInfo(dispatchIotServerPath).Parent.FullName.ToUpper()) { errMsg = dispatchServerName + "服务路径不一致,请先卸载原来路径的服务:" + curFilePath; statusCode = "4007"; return(""); } if (ServiceToolEx.IsServiceRunning(dispatchServerName)) { errMsg = dispatchServerName + "服务已经在运行"; statusCode = "4000"; return(""); } ServiceController service = ServiceToolEx.StartService(dispatchServerName, new string[0]); if (service == null) { errMsg = dispatchServerName + "服务启动失败"; statusCode = "4001"; } if (ServiceToolEx.IsServiceRunning(dispatchServerName)) { return(dispatchServerName + "服务已启动"); } else { errMsg = dispatchServerName + "服务启动失败!" + ErrorPolicy; statusCode = "4005"; return(""); } }