I have a template txt file (example):
test_asd = value
this is the end of the file
From which I need to create other text files with different values in the place of value
I'm writing a program to use this in C#
(using a child process cmd.exe
and commands)
I have tried setting an environment variable but the output is not different from the original template file.
test.txt:
test_asd = %VALUE%
this is the end of the file
C#:
Environment.SetEnvironmentVariable("VALUE", "test");
Process p = new Process();
ProcessStartInfo psi = new ProcessStartInfo();
psi.FileName = "cmd.exe";
psi.UseShellExecute = false;
psi.CreateNoWindow = true;
psi.RedirectStandardInput = true;
psi.RedirectStandardOutput = true;
p.StartInfo = psi;
p.Start();
p.StandardInput.WriteLine("type test.txt");
p.StandardInput.WriteLine("exit");
p.WaitForExit();
string output = p.StandardOutput.ReadToEnd();
Console.WriteLine(output);
Console.ReadLine(); // wait for 'Enter' to exit
Is there a way to do this?