How Can I run some Python Scripts in VS C++?

david bing.liu at gmail.com
Fri Feb 20 13:16:08 EST 2009


On Feb 20, 11:12 am, "Gabriel Genellina" <gagsl-... at yahoo.com.ar>
wrote:
> En Fri, 20 Feb 2009 15:47:06 -0200, david <bing.... at gmail.com> escribió:
>
> > Basically I have some python scripts to do some document processing,
> > all in command line tho.
> > I want to have an C++ application so that my scripts can run in dialogs
> > (API).
> > I saw a post before using c# to run python scripts within the c# main.
> > I am willing to run my python scripts within c++.
> > Thanks.
>
> So you want to execute a Python script, in a different process, as if you  
> typed the command line?
> That's not different to executing any other external program in C# - in  
> fact is a C# question, no Python involved. Try something like this:
>
>      Process p = new Process();
>      p.StartInfo.FileName = "path\to\python.exe";
>      p.StartInfo.Arguments = "path\to\your\script.py other arguments";
>      p.Start();
>      p.WaitForExit();
>      p.Close()
>
> There are other properties you may want to use, like  
> RedirectStandardOutput; see the C# documentation.
>
> --
> Gabriel Genellina

Thanks so much. I'll give it a try :)
Best Regards.

David



More information about the Python-list mailing list