DoEnvironmentSubst

[DllImport("shell32.dll", CharSet = CharSet.Unicode)]
public static extern uint DoEnvironmentSubst(
   StringBuilder pszPath,
   uint cchPath
);

Microsoft documentation: Link

Last updated