{"record":{"id":"9b782a4be628d8cb","repo":"elastic/elasticsearch","slug":"missing-procrun-exe-procrun","errorCode":null,"errorMessage":"Missing procrun exe: ${procrun}","messagePattern":"Missing procrun exe: (.+?)","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"critical","filePath":"distribution/tools/windows-service-cli/src/main/java/org/elasticsearch/windows/service/ProcrunCommand.java","lineNumber":65,"sourceCode":"        super(desc);\n        this.cmd = cmd;\n    }\n\n    /**\n     * Returns the name of the exe within the Elasticsearch bin dir to run.\n     *\n     * <p> Procrun comes with two executables, {@code prunsrv.exe} and {@code prunmgr.exe}. These are renamed by\n     * Elasticsearch to {@code elasticsearch-service-x64.exe} and {@code elasticsearch-service-mgr.exe}, respectively.\n     */\n    protected String getExecutable() {\n        return \"elasticsearch-service-x64.exe\";\n    }\n\n    @Override\n    protected void execute(Terminal terminal, OptionSet options, ProcessInfo processInfo) throws Exception {\n        Path procrun = processInfo.workingDir().resolve(\"bin\").resolve(getExecutable()).toAbsolutePath();\n        if (Files.exists(procrun) == false) {\n            throw new IllegalStateException(\"Missing procrun exe: \" + procrun);\n        }\n        String serviceId = getServiceId(options, processInfo.envVars());\n        preExecute(terminal, processInfo, serviceId);\n\n        List<String> procrunCmd = new ArrayList<>();\n        procrunCmd.add(quote(procrun.toString()));\n        procrunCmd.add(\"//%s/%s\".formatted(cmd, serviceId));\n        if (includeLogArgs()) {\n            procrunCmd.add(getLogArgs(serviceId, processInfo.workingDir(), processInfo.envVars()));\n        }\n        procrunCmd.add(getAdditionalArgs(serviceId, processInfo));\n\n        ProcessBuilder processBuilder = new ProcessBuilder(\"cmd.exe\", \"/C\", String.join(\" \", procrunCmd).trim());\n        logger.debug((Supplier<?>) () -> \"Running procrun: \" + String.join(\" \", processBuilder.command()));\n        processBuilder.inheritIO();\n        Process process = startProcess(processBuilder);\n        int ret = process.waitFor();\n        if (ret != ExitCodes.OK) {","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/distribution/tools/windows-service-cli/src/main/java/org/elasticsearch/windows/service/ProcrunCommand.java#L47-L83","documentation":"Thrown by ProcrunCommand.execute when the Windows service executable `elasticsearch-service-x64.exe` (the renamed Apache Commons Daemon prunsrv.exe) cannot be found in `bin/` under the working directory. The Windows service CLI shells out to this exe to install/remove/start/stop the service, so its absence makes the command unusable. IllegalStateException is used because the missing exe is a packaging/ installation defect rather than user input.","triggerScenarios":"Running `elasticsearch-service.bat install` from a distribution that does not include the Windows service binaries (the zip distribution includes them; some custom packages do not). Running from the source tree or a partial extraction. Working directory not set to ES_HOME so the relative `bin/elasticsearch-service-x64.exe` does not resolve.","commonSituations":"Deploying the tar.gz distribution (no Windows exes) on Windows by mistake. CI copying only a subset of files. Operators running the bat file from a non-standard CWD.","solutions":["Confirm the file exists: `dir %ES_HOME%\\bin\\elasticsearch-service-x64.exe`.","Use the Windows zip distribution (`elasticsearch-<version>-windows-x86_64.zip`) which ships the service exes.","Run the service CLI from ES_HOME so the relative bin/ path resolves, or set the working directory correctly.","Reinstall the Windows distribution if the exe was deleted."],"exampleFix":"REM before\ncd C:\\build\\elasticsearch-src\nbin\\elasticsearch-service.bat install\nREM after\ncd C:\\elasticsearch-9.1.0\nbin\\elasticsearch-service.bat install\ndir bin\\elasticsearch-service-x64.exe","handlingStrategy":"validation","validationCode":"Path exe = workingDir.resolve(\"bin\").resolve(\"elasticsearch-service-x64.exe\");\nif (!Files.isRegularFile(exe)) {\n    throw new IllegalStateException(\"Windows service exe missing at \" + exe + \"; use the Windows zip distribution.\");\n}","typeGuard":"static boolean hasProcrunExe(Path workingDir) {\n    return Files.isRegularFile(workingDir.resolve(\"bin/elasticsearch-service-x64.exe\"));\n}","tryCatchPattern":"try {\n    cmd.execute(terminal, options, processInfo);\n} catch (IllegalStateException e) {\n    if (e.getMessage().contains(\"Missing procrun exe\")) {\n        // direct operator to install the Windows zip distribution\n    } else throw e;\n}","preventionTips":["On Windows, always deploy the windows-x86_64 zip rather than the tar.gz.","Smoke-test `dir bin\\elasticsearch-service-x64.exe` after extraction.","Run service commands from ES_HOME so the relative bin path resolves."],"tags":["windows","service","procrun","cli","installation","filesystem"],"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-12T06:17:24.410Z"}