{"record":{"id":"f1067f464a39d0fb","repo":"OdysseusYuan/LKY_OfficeTools","slug":"serv-name-serv-description-f1067f","errorCode":null,"errorMessage":"尝试修改服务 {serv_name} 的描述信息为 {serv_description}，但该服务未安装！","messagePattern":"尝试修改服务 (.+?) 的描述信息为 (.+?)，但该服务未安装！","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"warning","filePath":"LKY_OfficeTools/Common/Com_ServiceOS.cs","lineNumber":476,"sourceCode":"                            //非空判断，若返回值为空，则为假\n                            if (string.IsNullOrEmpty(modify_result))\n                            {\n                                throw new Exception($\"执行修改 {serv_name} 描述信息时，返回值为空！\");\n                            }\n\n                            //判断是否修改描述成功\n                            if (modify_result.Contains(\"成功\") || modify_result.ToLower().Contains(\"success\"))\n                            {\n                                return true;\n                            }\n                            else\n                            {\n                                throw new Exception($\"修改服务 {serv_name} 的描述信息为 {serv_description} 失败！\");\n                            }\n                        }\n                        else\n                        {\n                            throw new Exception($\"尝试修改服务 {serv_name} 的描述信息为 {serv_description}，但该服务未安装！\");\n                        }\n                    }\n                    catch (Exception Ex)\n                    {\n                        new Log(Ex.ToString());\n                        return false;\n                    }\n                }\n            }\n        }\n    }\n}\n","sourceCodeStart":458,"sourceCodeEnd":489,"githubUrl":"https://github.com/OdysseusYuan/LKY_OfficeTools/blob/6f9a1bd471918f3310e6be4a6d7f42d0d6e467cf/LKY_OfficeTools/Common/Com_ServiceOS.cs#L458-L489","documentation":"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).","triggerScenarios":"Calling Modify.Description for an unregistered, already-deleted, or misspelled service, or when GetServices throws so IsCreated returns false.","commonSituations":"Configuration step before install; name drift; using DisplayName where ServiceName was required.","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."],"exampleFix":"// before\nCom_ServiceOS.Config.Modify.Description(name, desc);\n\n// after\nif (Com_ServiceOS.Query.IsCreated(name))\n    Com_ServiceOS.Config.Modify.Description(name, desc);","handlingStrategy":"validation","validationCode":"if (Com_ServiceOS.Query.IsCreated(serv_name))\n    Com_ServiceOS.Config.Modify.Description(serv_name, serv_description);\n// else: nothing to reconfigure","typeGuard":"static bool ServiceRegistered(string name) => Com_ServiceOS.Query.IsCreated(name);","tryCatchPattern":null,"preventionTips":["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."],"tags":["windows-service","scm","service-config","not-found"],"backgroundTag":null,"analyzedSha":"6f9a1bd471918f3310e6be4a6d7f42d0d6e467cf","analyzedAt":"2026-08-13T18:00:34.810Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}