JosefNemec/Playnite · warning · NotSupportedException

Only exe, bat and lnk files are supported.

Error message

Only exe, bat and lnk files are supported.

What it means

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.

Source

Thrown at source/Playnite/Common/Programs2.cs:121

                else
                {
                    program.Icon = data.Path;
                }

                return program;
            }
            else if (file.Extension?.EndsWith(".bat", StringComparison.OrdinalIgnoreCase) == true)
            {
                return new Program
                {
                    Path = file.FullName,
                    Name = Path.GetFileNameWithoutExtension(file.FullName),
                    WorkDir = Path.GetDirectoryName(file.FullName),
                    AppId = filePath.MD5()
                };
            }

            throw new NotSupportedException("Only exe, bat and lnk files are supported.");
        }

        public static void CreateShortcut(string executablePath, string arguments, string iconPath, string shortcutPath)
        {
            var shell = new IWshRuntimeLibrary.WshShell();
            var link = (IWshRuntimeLibrary.IWshShortcut)shell.CreateShortcut(shortcutPath);
            link.TargetPath = executablePath;
            link.WorkingDirectory = Path.GetDirectoryName(executablePath);
            link.Arguments = arguments;
            link.IconLocation = string.IsNullOrEmpty(iconPath) ? executablePath + ",0" : iconPath;
            link.Save();
        }

        public static Program GetLnkShortcutData(string lnkPath)
        {
            var shell = new IWshRuntimeLibrary.WshShell();
            var link = (IWshRuntimeLibrary.IWshShortcut)shell.CreateShortcut(lnkPath);
            return new Program()

View on GitHub (pinned to 5911f4e964)

Solutions

  1. Filter files to .exe/.lnk/.bat (case-insensitive) before invoking the factory.
  2. Map .cmd to .bat handling or wrap unsupported launchers in a .bat/.lnk.
  3. Skip and log unsupported extensions rather than letting the exception propagate.

Example fix

// before
var prog = Programs2.ProgramFrom FileInfo(fi);

// after
var ext = (fi.Extension ?? "").ToLowerInvariant();
if (ext != ".exe" && ext != ".lnk" && ext != ".bat")
{
    logger.Debug($"Skipping unsupported file type: {fi.FullName}");
    continue;
}
var prog = Programs2.ProgramFromFile(fi);
Defensive patterns

Strategy: validation

Validate before calling

var ext = (fi.Extension ?? "").ToLowerInvariant();
if (ext != ".exe" && ext != ".lnk" && ext != ".bat") return null;

Type guard

static bool IsSupportedLauncher(FileInfo fi)
{
    var e = (fi?.Extension ?? "").ToLowerInvariant();
    return e == ".exe" || e == ".lnk" || e == ".bat";
}

Try / catch

try { return Programs2.ProgramFromFile(fi); }
catch (NotSupportedException) { return null; /* unsupported extension */ }

Prevention

When it happens

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

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

Related errors


AI-assisted analysis of JosefNemec/Playnite@5911f4e964 (2026-08-13). Data as JSON: /api/errors/2d5ed9213a84b8fa. Report an issue: GitHub.