You can use Environment.ExpandEnvironmentVariables(variable);
The input doesn't need to be a single variable, it can be a 'query', like your path, with variables embedded and it will expand all those it finds/recognises. This is shown in the snippet at the link given:
String query = "My system drive is %SystemDrive% and my system root is %SystemRoot%";
str = Environment.ExpandEnvironmentVariables(query);
Console.WriteLine("ExpandEnvironmentVariables: {0} {1}", Environment.NewLine, str);