diff --git a/src/gsudo/AppSettings/PathPrecedenceSetting.cs b/src/gsudo/AppSettings/PathPrecedenceSetting.cs index 95bbe21..d4b1deb 100644 --- a/src/gsudo/AppSettings/PathPrecedenceSetting.cs +++ b/src/gsudo/AppSettings/PathPrecedenceSetting.cs @@ -51,6 +51,18 @@ public override void Save(string newValue, bool global) Logger.Instance.Log($"\"{system32Path}\" path is now prioritized in the PATH environment variable.", LogLevel.Info); Logger.Instance.Log("Please restart all your consoles to ensure the change makes effect.", LogLevel.Warning); + + // Notify the system of the change + SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, IntPtr.Zero, "Environment", SMTO_NORMAL, 100, out var _); } + + [System.Runtime.InteropServices.DllImport("user32.dll", SetLastError = true, CharSet = System.Runtime.InteropServices.CharSet.Auto)] + public static extern IntPtr SendMessageTimeout(IntPtr hWnd, uint Msg, IntPtr wParam, + [System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.LPTStr)] string lParam, + uint fuFlags, uint uTimeout, out IntPtr lpdwResult); + + private static readonly IntPtr HWND_BROADCAST = new IntPtr(0xFFFF); + private const uint WM_SETTINGCHANGE = 0x001A; + private const uint SMTO_NORMAL = 0x0000; } }