tags:

views:

128

answers:

4

so i need a simple function to run bat file. How to do such thing?

+8  A: 

Take a look at Process.Start

In the simplest form, you can call it like this

Process.Start("thebatchfile.bat")
Chris Taylor
+12  A: 

Process.Start("file.bat");

ChrisF
+1  A: 

You may find you need to include the directory in the call;

using System.Diagnostics;

Process.Start(@"C:....\thebatfile.bat");

If for example the file takes arguments in (not for Bat file granted), they too can be added in the "Start()"method. Seperate Start("....thebatfile", "-s - t 3600"); with a comma. Intellisense is great for looking at the overload options of the method.

Stephen Murby
+1  A: 

I don't know how this is any different, but in a project I inherited, we used Microsoft.VisualBasic.Interaction.Shell.

Shell("file.bat", AppWinStyle.NormalFocus, True, -1) The last two parameters specify if the calling program should wait for the command to finish, and how long it should wait for it to time out (-1 for forever)

Rice Flour Cookies