OdysseusYuan/LKY_OfficeTools · warning · Exception
尝试修改服务 {serv_name} 的描述信息为 {serv_description},但该服务未安装!
Error message
尝试修改服务 {serv_name} 的描述信息为 {serv_description},但该服务未安装! What it means
Thrown in Com_ServiceOS.Config.Modify.Description's else-branch when Query.IsCreated(serv_name) is false at entry (Com_ServiceOS.cs:474-477), guarding against editing a non-existent service. The throw is caught by Description's own catch and it returns false (Com_ServiceOS.cs:479-483).
Source
Thrown at LKY_OfficeTools/Common/Com_ServiceOS.cs:476
//非空判断,若返回值为空,则为假
if (string.IsNullOrEmpty(modify_result))
{
throw new Exception($"执行修改 {serv_name} 描述信息时,返回值为空!");
}
//判断是否修改描述成功
if (modify_result.Contains("成功") || modify_result.ToLower().Contains("success"))
{
return true;
}
else
{
throw new Exception($"修改服务 {serv_name} 的描述信息为 {serv_description} 失败!");
}
}
else
{
throw new Exception($"尝试修改服务 {serv_name} 的描述信息为 {serv_description},但该服务未安装!");
}
}
catch (Exception Ex)
{
new Log(Ex.ToString());
return false;
}
}
}
}
}
}
View on GitHub (pinned to 6f9a1bd471)
Solutions
- Pre-check Query.IsCreated and Create the service first if absent.
- Verify the ServiceName with `sc query`.
- Treat false as 'service not present; nothing to change'.
- Order Create before Modify.
Example fix
// before
Com_ServiceOS.Config.Modify.Description(name, desc);
// after
if (Com_ServiceOS.Query.IsCreated(name))
Com_ServiceOS.Config.Modify.Description(name, desc); Defensive patterns
Strategy: validation
Validate before calling
if (Com_ServiceOS.Query.IsCreated(serv_name))
Com_ServiceOS.Config.Modify.Description(serv_name, serv_description);
// else: nothing to reconfigure Type guard
static bool ServiceRegistered(string name) => Com_ServiceOS.Query.IsCreated(name);
Prevention
- Pre-check IsCreated before Modify; Create must precede Modify.
- Treat the false return as 'service not present'.
- Confirm ServiceName with `sc query`.
- Order install before any configuration step.
When it happens
Trigger: Calling Modify.Description for an unregistered, already-deleted, or misspelled service, or when GetServices throws so IsCreated returns false.
Common situations: Configuration step before install; name drift; using DisplayName where ServiceName was required.
Related errors
- 尝试修改服务 {serv_name} 的 binPath 信息为 {serv_binpath},但该服务未安装!
- 尝试修改服务 {serv_name} 的 DisplayName 信息为 {serv_displayname},但该服务
- 没有找到名称为 {serv_name} 的服务,无法删除该服务!
- 执行修改 {serv_name} binPath 参数时,返回值为空!
- 修改服务 {serv_name} 的 binPath 信息为 {serv_binpath} 失败!
AI-assisted analysis of OdysseusYuan/LKY_OfficeTools@6f9a1bd471 (2026-08-13).
Data as JSON: /api/errors/f1067f464a39d0fb.
Report an issue: GitHub.