ShareX/ShareX · error · InvalidOperationException

Failed to start ExifTool.

Error message

Failed to start ExifTool.

What it means

Thrown by MetadataService.RunExifToolAsync when Process.Start(startInfo) returns null. On .NET Process.Start returns null only in rare provider-specific cases (normally it throws), so this guard covers the edge where the process could not be launched at all.

Source

Thrown at ShareX.Tools/Tools/Metadata/MetadataService.cs:68

            throw new FileNotFoundException(Localization.Strings.MetadataService_Selected_file_not_found, filePath);
        }

        ProcessStartInfo startInfo = new()
        {
            FileName = ExifToolPath,
            RedirectStandardOutput = true,
            RedirectStandardError = true,
            UseShellExecute = false,
            CreateNoWindow = true
        };
        startInfo.ArgumentList.Add(filePath);
        foreach (string argument in arguments)
        {
            startInfo.ArgumentList.Add(argument);
        }

        using Process process = Process.Start(startInfo)
            ?? throw new InvalidOperationException(Localization.Strings.MetadataService_Failed_start_ExifTool);
        Task<string> outputTask = process.StandardOutput.ReadToEndAsync(cancellationToken);
        Task<string> errorTask = process.StandardError.ReadToEndAsync(cancellationToken);
        await process.WaitForExitAsync(cancellationToken);
        string output = await outputTask;
        string error = await errorTask;

        if (process.ExitCode != 0)
        {
            throw new InvalidOperationException(string.IsNullOrWhiteSpace(error)
                ? string.Format(Localization.Strings.MetadataService_Exited_with_code, process.ExitCode)
                : error.Trim());
        }

        return output;
    }
}

View on GitHub (pinned to f7d4b6bfbf)

Solutions

  1. Confirm ExifToolPath points to a genuine, runnable executable (check it is a valid PE and architecture-matched).
  2. Run the binary manually from a shell to confirm it launches.
  3. Check antivirus/defender or group policy is not silently blocking process creation.

Example fix

// before
using Process process = Process.Start(startInfo) ?? throw new InvalidOperationException("Failed to start ExifTool.");

// after
using Process process = Process.Start(startInfo)
    ?? throw new InvalidOperationException($"Process.Start returned null for '{ExifToolPath}'. Verify the file is a valid executable.");
Defensive patterns

Strategy: try-catch

Validate before calling

// Validate the binary is a real executable before launching
if (!File.Exists(ExifToolPath)) throw new FileNotFoundException("ExifTool missing.", ExifToolPath);
// (no trivial managed check that Start will succeed; rely on try/catch)

Type guard

static bool LooksExecutable(string path) => File.Exists(path) && (path.EndsWith(".exe", StringComparison.OrdinalIgnoreCase) || path.EndsWith("exiftool"));

Try / catch

try { using var p = Process.Start(startInfo) ?? throw new InvalidOperationException("Start returned null."); }
catch (InvalidOperationException ex) { /* verify binary integrity, re-download ExifTool */ }
catch (Win32Exception ex) { /* surface native launch failure */ }

Prevention

When it happens

Trigger: Process.Start returns null for the configured ExifToolPath; can happen with a non-executable file masquerading as the binary, a broken process launch provider, or when the FileName cannot be executed as a process (e.g. a document instead of an exe).

Common situations: ExifToolPath exists as a file but is not actually executable (corrupt download, 0-byte, wrong architecture); permissions prevent launching; sandbox blocks process creation.

Related errors


AI-assisted analysis of ShareX/ShareX@f7d4b6bfbf (2026-08-13). Data as JSON: /api/errors/3973b375edff32ef. Report an issue: GitHub.