As long as you have no variables or nonsingleline-commands you can run this function with each line of the bat-file
internal static void executeCommand(string command, bool waitForExit,
bool hideWindow, bool runAsAdministrator)
{
System.Diagnostics.ProcessStartInfo psi =
new System.Diagnostics.ProcessStartInfo("cmd", "/C " + command);
if (hideWindow)
{
psi.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
}
if (runAsAdministrator)
{
psi.Verb = "runas";
}
if (waitForExit)
{
System.Diagnostics.Process.Start(psi).WaitForExit();
}
else
{
System.Diagnostics.Process.Start(psi);
}
}
so you can also save the text in the code
string bat_file = @"@echo off
copy c:usersDesktopfilea.txt c:usersDesktopfileb.txt
...";
otherwise i would create a temporary bat file, run it and delete it.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…