{"record":{"id":"2d5ed9213a84b8fa","repo":"JosefNemec/Playnite","slug":"only-exe-bat-and-lnk-files-are-supported","errorCode":null,"errorMessage":"Only exe, bat and lnk files are supported.","messagePattern":"Only exe, bat and lnk files are supported\\.","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"warning","filePath":"source/Playnite/Common/Programs2.cs","lineNumber":121,"sourceCode":"                else\r\n                {\r\n                    program.Icon = data.Path;\r\n                }\r\n\r\n                return program;\r\n            }\r\n            else if (file.Extension?.EndsWith(\".bat\", StringComparison.OrdinalIgnoreCase) == true)\r\n            {\r\n                return new Program\r\n                {\r\n                    Path = file.FullName,\r\n                    Name = Path.GetFileNameWithoutExtension(file.FullName),\r\n                    WorkDir = Path.GetDirectoryName(file.FullName),\r\n                    AppId = filePath.MD5()\r\n                };\r\n            }\r\n\r\n            throw new NotSupportedException(\"Only exe, bat and lnk files are supported.\");\r\n        }\r\n\r\n        public static void CreateShortcut(string executablePath, string arguments, string iconPath, string shortcutPath)\r\n        {\r\n            var shell = new IWshRuntimeLibrary.WshShell();\r\n            var link = (IWshRuntimeLibrary.IWshShortcut)shell.CreateShortcut(shortcutPath);\r\n            link.TargetPath = executablePath;\r\n            link.WorkingDirectory = Path.GetDirectoryName(executablePath);\r\n            link.Arguments = arguments;\r\n            link.IconLocation = string.IsNullOrEmpty(iconPath) ? executablePath + \",0\" : iconPath;\r\n            link.Save();\r\n        }\r\n\r\n        public static Program GetLnkShortcutData(string lnkPath)\r\n        {\r\n            var shell = new IWshRuntimeLibrary.WshShell();\r\n            var link = (IWshRuntimeLibrary.IWshShortcut)shell.CreateShortcut(lnkPath);\r\n            return new Program()\r","sourceCodeStart":103,"sourceCodeEnd":139,"githubUrl":"https://github.com/JosefNemec/Playnite/blob/5911f4e964e628aa7a69c2030ab35101afa63067/source/Playnite/Common/Programs2.cs#L103-L139","documentation":"Thrown by Programs2 when resolving a FileInfo into a Program and the file extension is neither .exe, .lnk, nor .bat. It is a NotSupportedException indicating the file type is not one Playnite knows how to launch/describe.","triggerScenarios":"Calling the Program factory on a .cmd/.ps1/.appref-ms/.url/.jar/.com or extension-less file; a file whose Extension property is null or does not match the three supported extensions case-insensitively.","commonSituations":"Scanning a directory that contains shortcuts/scripts of unsupported types; user adds a .url internet shortcut or .appref-ms ClickOnce entry; imported action pointing at a non-standard launcher.","solutions":["Filter files to .exe/.lnk/.bat (case-insensitive) before invoking the factory.","Map .cmd to .bat handling or wrap unsupported launchers in a .bat/.lnk.","Skip and log unsupported extensions rather than letting the exception propagate."],"exampleFix":"// before\nvar prog = Programs2.ProgramFrom FileInfo(fi);\n\n// after\nvar ext = (fi.Extension ?? \"\").ToLowerInvariant();\nif (ext != \".exe\" && ext != \".lnk\" && ext != \".bat\")\n{\n    logger.Debug($\"Skipping unsupported file type: {fi.FullName}\");\n    continue;\n}\nvar prog = Programs2.ProgramFromFile(fi);","handlingStrategy":"validation","validationCode":"var ext = (fi.Extension ?? \"\").ToLowerInvariant();\nif (ext != \".exe\" && ext != \".lnk\" && ext != \".bat\") return null;","typeGuard":"static bool IsSupportedLauncher(FileInfo fi)\n{\n    var e = (fi?.Extension ?? \"\").ToLowerInvariant();\n    return e == \".exe\" || e == \".lnk\" || e == \".bat\";\n}","tryCatchPattern":"try { return Programs2.ProgramFromFile(fi); }\ncatch (NotSupportedException) { return null; /* unsupported extension */ }","preventionTips":["Filter scanned files to .exe/.lnk/.bat before resolving programs.","Wrap unsupported launchers (.cmd/.url/.appref-ms) in a .bat or .lnk.","Skip and log unsupported types rather than throwing."],"tags":["programs","validation","file-type","playnite"],"backgroundTag":null,"analyzedSha":"5911f4e964e628aa7a69c2030ab35101afa63067","analyzedAt":"2026-08-13T17:38:25.713Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}