Hi,
Another couple of things that you need to be care of:
1- Create a pif file and check "Close on Exit" , otherwise you wil have a
DOS screen saying something like "FINISHED Program Name"
2- If you do not want that the DOS windows is shown select Normal as the
windows mode in the PIF's creation dialog ( also take a look at the code
below )
This is the code I'm using to exec a bat:
Process proc = new Process();
proc.StartInfo.FileName = foxexe;
proc.StartInfo.Arguments = prg;
proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
proc.StartInfo.ErrorDialog = false;
proc.StartInfo.WorkingDirectory = Path.GetDirectoryName( prg);
proc.Start();
proc.WaitForExit();
if ( proc.ExitCode!= 0 )
throw new Exception("Error executing foxpro");
Hope this help,
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
Matteo Taveggia said:
Correct. Here is a sample code snippet you can paste into your Main function:
System.Diagnostics.ProcessStartInfo p = new System.Diagnostics.ProcessStartInfo(@"c:\foo.bat");
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.StartInfo = p;
proc.Start();
proc.WaitForExit();
Console.WriteLine("I'm done");
Note: you might tweak it a little bit your code (or batch file) to
allow/avoid async execution (it really depends on what you are trying to
do).
rights. Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
Note: For the benefit of the community-at-large, all responses to this
message are best directed to the newsgroup/thread from which they
originated.