[Mono-devel-list] Call one Exe From another

Jonathan Gilbert 2a5gjx302 at sneakemail.com
Thu Jan 27 13:07:36 EST 2005


At 04:39 AM 27/01/2005 -0200, Everaldo Canuto wrote:
>Hi, 
>
>FileName is a name of your file executable, and Arguments is a arguments
>for command line, see this command line:
>
>mono WindowText.exe par1 par2
>
>"mono" - is FileName
>"WindowText.exe par1 par2" is Arguments.
>
>
>Try to do this:
>
>System.Diagnostics.Process proc = new System.Diagnostics.Process();
>proc.EnableRaisingEvents=false;
>proc.StartInfo.FileName="mono";
>proc.StartInfo.Arguments="WindowTest.exe";
>proc.Start(); 
>proc.WaitForExit();
>
>Best regards,
>Everaldo.

Perhaps it would be an idea to have mono check the 'FileName' argument to
see if it is a .NET executable; if it is, and the current executable is
(obviously) running under mono, it makes sense that the user probably wants
the other executable to also run under mono. So, if mono detects this pattern:

Process proc = new Process();
proc.StartInfo.FileName = "WindowTest.exe";
proc.Start();
proc.WaitForExit();

..and it can see that WindowTest.exe is a .NET binary, it will
automatically invoke 'mono WindowTest.exe' instead of trying to invoke
'WindowTest.exe' directly. This would, of course, make the user code
compatible between mono & MS.NET; MS.NET, without the translation, would
simply invoke the .NET binary normally, bringing it up within the .NET
framework.

If I knew how to detect whether a binary is a .NET binary, I'd offer to
make the changes myself :-)

Jonathan Gilbert




More information about the Mono-devel-list mailing list