elastic/elasticsearch · critical · IllegalStateException

Missing procrun exe: ${procrun}

Error message

Missing procrun exe: ${procrun}

What it means

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.

Source

Thrown at distribution/tools/windows-service-cli/src/main/java/org/elasticsearch/windows/service/ProcrunCommand.java:65

        super(desc);
        this.cmd = cmd;
    }

    /**
     * Returns the name of the exe within the Elasticsearch bin dir to run.
     *
     * <p> Procrun comes with two executables, {@code prunsrv.exe} and {@code prunmgr.exe}. These are renamed by
     * Elasticsearch to {@code elasticsearch-service-x64.exe} and {@code elasticsearch-service-mgr.exe}, respectively.
     */
    protected String getExecutable() {
        return "elasticsearch-service-x64.exe";
    }

    @Override
    protected void execute(Terminal terminal, OptionSet options, ProcessInfo processInfo) throws Exception {
        Path procrun = processInfo.workingDir().resolve("bin").resolve(getExecutable()).toAbsolutePath();
        if (Files.exists(procrun) == false) {
            throw new IllegalStateException("Missing procrun exe: " + procrun);
        }
        String serviceId = getServiceId(options, processInfo.envVars());
        preExecute(terminal, processInfo, serviceId);

        List<String> procrunCmd = new ArrayList<>();
        procrunCmd.add(quote(procrun.toString()));
        procrunCmd.add("//%s/%s".formatted(cmd, serviceId));
        if (includeLogArgs()) {
            procrunCmd.add(getLogArgs(serviceId, processInfo.workingDir(), processInfo.envVars()));
        }
        procrunCmd.add(getAdditionalArgs(serviceId, processInfo));

        ProcessBuilder processBuilder = new ProcessBuilder("cmd.exe", "/C", String.join(" ", procrunCmd).trim());
        logger.debug((Supplier<?>) () -> "Running procrun: " + String.join(" ", processBuilder.command()));
        processBuilder.inheritIO();
        Process process = startProcess(processBuilder);
        int ret = process.waitFor();
        if (ret != ExitCodes.OK) {

View on GitHub (pinned to db6a809a66)

Solutions

  1. Confirm the file exists: `dir %ES_HOME%\bin\elasticsearch-service-x64.exe`.
  2. Use the Windows zip distribution (`elasticsearch-<version>-windows-x86_64.zip`) which ships the service exes.
  3. Run the service CLI from ES_HOME so the relative bin/ path resolves, or set the working directory correctly.
  4. Reinstall the Windows distribution if the exe was deleted.

Example fix

REM before
cd C:\build\elasticsearch-src
bin\elasticsearch-service.bat install
REM after
cd C:\elasticsearch-9.1.0
bin\elasticsearch-service.bat install
dir bin\elasticsearch-service-x64.exe
Defensive patterns

Strategy: validation

Validate before calling

Path exe = workingDir.resolve("bin").resolve("elasticsearch-service-x64.exe");
if (!Files.isRegularFile(exe)) {
    throw new IllegalStateException("Windows service exe missing at " + exe + "; use the Windows zip distribution.");
}

Type guard

static boolean hasProcrunExe(Path workingDir) {
    return Files.isRegularFile(workingDir.resolve("bin/elasticsearch-service-x64.exe"));
}

Try / catch

try {
    cmd.execute(terminal, options, processInfo);
} catch (IllegalStateException e) {
    if (e.getMessage().contains("Missing procrun exe")) {
        // direct operator to install the Windows zip distribution
    } else throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of elastic/elasticsearch@db6a809a66 (2026-08-12). Data as JSON: /api/errors/9b782a4be628d8cb. Report an issue: GitHub.