Hello. I tried to implement ypour suggestion, but an error apears: "Exception System.ComponentModel.Win32Exception was thrown in debugee: The specified executable is not a valid Win32 application.
StartWithCreateProcess() Start() Start() Main() - c:\Documents and Settings\Zlatko\My Documents\SharpDevelop Projects\CS_script\CS_script\Main.cs:32,5 " The C# code is the following: /* * Created by SharpDevelop. * User: Zlatko * Date: 28.5.2006 * Time: 9:38 * * To change this template use Tools | Options | Coding | Edit Standard Headers. */ using System; using System.Collections.Generic; using System.Diagnostics; using System.Windows.Forms; namespace CS_script { class MainClass { public static void Main(string[] args) { System.Diagnostics.ProcessStartInfo psi =new System.Diagnostics.ProcessStartInfo(); psi.FileName="my_script.py"; psi.WorkingDirectory=Environment.CurrentDirectory; psi.RedirectStandardOutput = true; psi.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; psi.UseShellExecute = false; psi.CreateNoWindow = true; System.Diagnostics.Process script; script = System.Diagnostics.Process.Start(psi); System.IO.StreamReader myOutput = script.StandardOutput; script.WaitForExit(2000); if (script.HasExited) { string output = myOutput.ReadToEnd(); //this.processResults.Text = output; } MessageBox.Show("finished!"); } } } When running the program, I have the following error: "Exception System.ComponentModel.Win32Exception was thrown in debugee: The specified executable is not a valid Win32 application. StartWithCreateProcess() Start() Start() Main() - c:\Documents and Settings\Zlatko\My Documents\SharpDevelop Projects\CS_script\CS_script\Main.cs:32,5 " "Gerard Flanagan" <[EMAIL PROTECTED]> je napisao u poruci interesnoj grupi:[EMAIL PROTECTED] > tatamata wrote: >> Hello. >> >> How can I run some Python script within C# program? >> > > --------------------------------------------------------------------------------- > ProcessStartInfo startInfo; > Process process; > string directory; > string pyArgs; > string script; > > startInfo = new ProcessStartInfo("python"); > startInfo.WorkingDirectory = directory; > startInfo.Arguments = script + " " + pyArgs; > startInfo.UseShellExecute = false; > startInfo.CreateNoWindow = true; > startInfo.RedirectStandardOutput = true; > startInfo.RedirectStandardError = true; > > process = new Process(); > process.StartInfo = startInfo; > process.Start(); > > string s; > while ((s = process.StandardOutput.ReadLine()) != null) > { > //do something with s > } > --------------------------------------------------------------------------------- > > HTH > > Gerard > -- http://mail.python.org/mailman/listinfo/python-list