detectWinget function

bool detectWinget()

Detects if the currently running instance was installed via winget. Winget installs to %LOCALAPPDATA%\Microsoft\WinGet\Packages or C:\Program Files\WinGet\Packages.

Implementation

bool detectWinget() {
  if (!Platform.isWindows) return false;
  final execPath = Platform.resolvedExecutable;
  final patterns = [
    RegExp(r'Microsoft[/\\]WinGet[/\\]Packages', caseSensitive: false),
    RegExp(r'Microsoft[/\\]WinGet[/\\]Links', caseSensitive: false),
  ];
  return patterns.any((p) => p.hasMatch(execPath));
}