3
I am making a program in C# and in it I run a file . bat
Look how I turn the file:
string batDir = string.Format(@"C:\Users\Desktop");
proc = new Process();
proc.StartInfo.WorkingDirectory = batDir;
proc.StartInfo.FileName = "teste4.bat";
proc.StartInfo.CreateNoWindow = false;
proc.Start();
proc.WaitForExit();
MessageBox.Show("Bat file executed !!");
}
catch (Exception ex)
{
Console.WriteLine(ex.StackTrace.ToString());
}
But now I need create an archive .bat directly from c#. I wish I could write a command to c# and create a file .bat storing this command.
How can I do that? I know that to create a file .txt We use the function:
StreamWriter EscreverTXT = new StreamWriter(@"Disco:local\nomeTXT.log");
EscreverTXT.WriteLine(stringArmazenandoComando);
EscreverTXT.Close();
Now, how to do this except instead of TXT, write a BAT ?
A
.bat
is a text equal to.txt
, only it has another extension.– Maniero
thanks! I got it here
– Pedro Stelita Vieira