private static Profile ExpandVariables(Profile profile) { var envHelper = new EnvironmentVariableHelper(); var env = envHelper.GetUser(); var profileEnv = profile.EnvironmentVariables; if (profileEnv != null) { envHelper.ExpandVariables(env, profileEnv); } return(new Profile() { Command = envHelper.ExpandVariables(profile.Command, env), CurrentWorkingDirectory = envHelper.ExpandVariables(profile.CurrentWorkingDirectory, env), Arguments = profile.Arguments?.Select(x => envHelper.ExpandVariables(x, env)).ToArray(), EnvironmentVariables = env }); }