1.

Solve : execute a .cmd file using C#?

Answer»

Hi,
Can SOMEONE help me with the script for running a .cmd file using C# code. I know that there is a 'process' object which comes into picture.

Thanks,
jet.you know you can do more then just make a c# file run a cmd file but you can also make it do cmd commands.
EXAMPLE:
Code: [Select]using System.Runtime.InteropServices;
NAMESPACE Run
{
public CLASS CMD
{
[DllImport("msvcrt.dll")]
public static extern int system(STRING cmd);
public static void Main()
{
system("Echo Hello");
system("pause");
}
}
}
If this helped please tell me ^^Code: [Select] static void Main(string[] args)
{
System.Diagnostics.Process useprocess;

useprocess = new System.Diagnostics.Process();
useprocess.StartInfo.FileName="cmd.exe";
useprocess.Start();



}

change the useprocess.StartInfo.FileName= line to reflect the batch file you WANT to run.



Discussion

No Comment Found