JosefNemec/Playnite · error · Exception

URL file doesn't have shortcut definition section.

Error message

URL file doesn't have shortcut definition section.

What it means

Thrown when parsing a .url file (Internet Shortcut) whose INI content lacks the required [InternetShortcut] section. GetGameFromExecutable reads the file via IniParser and indexes urlData["InternetShortcut"]; a null section means the file is malformed or is not actually a URL shortcut.

Source

Thrown at source/Playnite/Extensions/GameExtensions.cs:122

                        game.Icon = iconPath;
                    }
                    else if (iconPath.Contains("Program Files (x86)"))
                    {
                        iconPath = iconPath.Replace("Program Files (x86)", "Program Files");
                        if (File.Exists(iconPath))
                        {
                            game.Icon = iconPath;
                        }
                    }
                }
            }
            else if (string.Equals(Path.GetExtension(path), ".url", StringComparison.OrdinalIgnoreCase))
            {
                var urlData = IniParser.Parse(File.ReadAllLines(path));
                var shortcut = urlData["InternetShortcut"];
                if (shortcut == null)
                {
                    throw new Exception("URL file doesn't have shortcut definition section.");
                }

                game.Name = Path.GetFileNameWithoutExtension(path);
                game.Icon = shortcut["IconFile"];
                game.GameActions = new System.Collections.ObjectModel.ObservableCollection<GameAction>
                {
                    new GameAction()
                    {
                        Type = GameActionType.URL,
                        Path = shortcut["URL"],
                        IsPlayAction = true,
                        Name = game.Name
                    }
                };
            }
            else
            {
                var file = new FileInfo(path);

View on GitHub (pinned to 5911f4e964)

Solutions

  1. Pre-parse and validate that the .url file contains an [InternetShortcut] section before calling GetGameFromExecutable.
  2. Reject non-standard .url files at the import UI with a clear message.
  3. If the file is suspect, read and inspect its first lines for the section header.

Example fix

// before
var shortcut = urlData["InternetShortcut"];
if (shortcut == null) { throw new Exception("URL file doesn't have shortcut definition section."); }

// after — caller pre-validation
var lines = File.ReadAllLines(path);
if (!lines.Any(l => l.Trim() == "[InternetShortcut]")) {
    logger.Warn($"{path} is not a valid Internet Shortcut.");
    return null;
}
Defensive patterns

Strategy: validation

Validate before calling

// Validate .url structure before import.
if (Path.GetExtension(path).Equals(".url", StringComparison.OrdinalIgnoreCase)) {
    var text = File.ReadAllText(path);
    if (!text.Contains("[InternetShortcut]")) { logger.Warn($"Invalid .url: {path}"); return null; }
}

Type guard

static bool IsValidUrlShortcut(string path) =>
    File.Exists(path) && File.ReadAllText(path).Contains("[InternetShortcut]");

Prevention

When it happens

Trigger: GetGameFromExecutable is called on a .url file whose contents do not contain an [InternetShortcut] header — e.g. a renamed text file, a truncated/corrupt shortcut, or a .url produced by a non-standard tool.

Common situations: User selected a .url file that is actually a different format; the shortcut was partially written or edited manually; encoding issues strip the section header.

Related errors


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