{"record":{"id":"3973b375edff32ef","repo":"ShareX/ShareX","slug":"failed-to-start-exiftool","errorCode":null,"errorMessage":"Failed to start ExifTool.","messagePattern":"Failed to start ExifTool\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"ShareX.Tools/Tools/Metadata/MetadataService.cs","lineNumber":68,"sourceCode":"            throw new FileNotFoundException(Localization.Strings.MetadataService_Selected_file_not_found, filePath);\r\n        }\r\n\r\n        ProcessStartInfo startInfo = new()\r\n        {\r\n            FileName = ExifToolPath,\r\n            RedirectStandardOutput = true,\r\n            RedirectStandardError = true,\r\n            UseShellExecute = false,\r\n            CreateNoWindow = true\r\n        };\r\n        startInfo.ArgumentList.Add(filePath);\r\n        foreach (string argument in arguments)\r\n        {\r\n            startInfo.ArgumentList.Add(argument);\r\n        }\r\n\r\n        using Process process = Process.Start(startInfo)\r\n            ?? throw new InvalidOperationException(Localization.Strings.MetadataService_Failed_start_ExifTool);\r\n        Task<string> outputTask = process.StandardOutput.ReadToEndAsync(cancellationToken);\r\n        Task<string> errorTask = process.StandardError.ReadToEndAsync(cancellationToken);\r\n        await process.WaitForExitAsync(cancellationToken);\r\n        string output = await outputTask;\r\n        string error = await errorTask;\r\n\r\n        if (process.ExitCode != 0)\r\n        {\r\n            throw new InvalidOperationException(string.IsNullOrWhiteSpace(error)\r\n                ? string.Format(Localization.Strings.MetadataService_Exited_with_code, process.ExitCode)\r\n                : error.Trim());\r\n        }\r\n\r\n        return output;\r\n    }\r\n}\r\n","sourceCodeStart":50,"sourceCodeEnd":85,"githubUrl":"https://github.com/ShareX/ShareX/blob/f7d4b6bfbf58c0553c01fb038347deec54c0cc7a/ShareX.Tools/Tools/Metadata/MetadataService.cs#L50-L85","documentation":"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.","triggerScenarios":"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).","commonSituations":"ExifToolPath exists as a file but is not actually executable (corrupt download, 0-byte, wrong architecture); permissions prevent launching; sandbox blocks process creation.","solutions":["Confirm ExifToolPath points to a genuine, runnable executable (check it is a valid PE and architecture-matched).","Run the binary manually from a shell to confirm it launches.","Check antivirus/defender or group policy is not silently blocking process creation."],"exampleFix":"// before\nusing Process process = Process.Start(startInfo) ?? throw new InvalidOperationException(\"Failed to start ExifTool.\");\n\n// after\nusing Process process = Process.Start(startInfo)\n    ?? throw new InvalidOperationException($\"Process.Start returned null for '{ExifToolPath}'. Verify the file is a valid executable.\");","handlingStrategy":"try-catch","validationCode":"// Validate the binary is a real executable before launching\nif (!File.Exists(ExifToolPath)) throw new FileNotFoundException(\"ExifTool missing.\", ExifToolPath);\n// (no trivial managed check that Start will succeed; rely on try/catch)","typeGuard":"static bool LooksExecutable(string path) => File.Exists(path) && (path.EndsWith(\".exe\", StringComparison.OrdinalIgnoreCase) || path.EndsWith(\"exiftool\"));","tryCatchPattern":"try { using var p = Process.Start(startInfo) ?? throw new InvalidOperationException(\"Start returned null.\"); }\ncatch (InvalidOperationException ex) { /* verify binary integrity, re-download ExifTool */ }\ncatch (Win32Exception ex) { /* surface native launch failure */ }","preventionTips":["Ensure ExifToolPath is a valid executable for the OS architecture.","Checksum-verify the downloaded binary.","Catch Win32Exception too, since most launch failures throw rather than return null."],"tags":["metadata","exiftool","external-process","process-start"],"backgroundTag":null,"analyzedSha":"f7d4b6bfbf58c0553c01fb038347deec54c0cc7a","analyzedAt":"2026-08-13T10:23:46.548Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}