resolveExecutable static method

String resolveExecutable(
  1. String name
)

  1. Resolve Executable (Windows Support)

Implementation

static String resolveExecutable(String name) {
  if (!Platform.isWindows) return name;
  final exts = ['.exe', '.bat', '.cmd'];
  for (final ext in exts) {
    final full = '$name$ext';
    final result = Process.runSync('where', [full], runInShell: true);
    if (result.exitCode == 0) {
      return result.stdout.toString().split('\n').first.trim();
    }
  }
  return name;
}