From 58718ef13621413457928fee6d0cb3619d3620f7 Mon Sep 17 00:00:00 2001 From: Arash Zandi Date: Wed, 18 Sep 2024 22:16:32 +0330 Subject: [PATCH] Look for FFmpeg in both user-wide and system-wide `PATH` locations (#495) --- YoutubeDownloader.Core/Downloading/FFmpeg.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/YoutubeDownloader.Core/Downloading/FFmpeg.cs b/YoutubeDownloader.Core/Downloading/FFmpeg.cs index 2376cf805..1ae4828d0 100644 --- a/YoutubeDownloader.Core/Downloading/FFmpeg.cs +++ b/YoutubeDownloader.Core/Downloading/FFmpeg.cs @@ -17,9 +17,17 @@ static IEnumerable GetProbeDirectoryPaths() yield return AppContext.BaseDirectory; yield return Directory.GetCurrentDirectory(); - if (Environment.GetEnvironmentVariable("PATH")?.Split(Path.PathSeparator) is { } paths) + // User PATH environment variable + if (Environment.GetEnvironmentVariable("PATH", EnvironmentVariableTarget.User)?.Split(Path.PathSeparator) is { } userPaths) { - foreach (var path in paths) + foreach (var path in userPaths) + yield return path; + } + + // System PATH environment variable + if (Environment.GetEnvironmentVariable("PATH", EnvironmentVariableTarget.Machine)?.Split(Path.PathSeparator) is { } systemPaths) + { + foreach (var path in systemPaths) yield return path; } }