Can't run exe file using System.Diagnostics.Process

Created at 07 Nov 2022, 10:10
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
ME

medvedilich

Joined 07.11.2022

Can't run exe file using System.Diagnostics.Process
07 Nov 2022, 10:10


protected override void OnStart()
{
            var program = new Process {
                StartInfo = {
                    FileName = "python.exe",
                    WorkingDirectory = @"C:\Users\alan\AppData\Local\Spotware\cTrader\4a28ae902aa17e9068eea37241a33c59\app_4.2.22.8450",
                    Arguments = "d:/программирование/python/test.py"
                }
            };
            program.Start();

}

When I run this code, there is a message in the log: 'Crashed in OnStart with Win32Exception: An error occurred trying to start process 'python.exe' with working directory 'C:\Users\alan\AppData\Local\Spotware\cTrader\4a28ae902aa17e9068eea37241a33c59\app_4.2.22.8450'. Unknown error (0x2)'

However, it works in Visual Studio in console app, and python file executes.


@medvedilich
Replies

winsonet
18 Feb 2023, 14:23 ( Updated at: 21 Dec 2023, 09:23 )

RE:

it's need to use the below for .Net 6


 

Process.Start( new ProcessStartInfo { FileName = @"http://. . . .", UseShellExecute = true } );

Process.Start( new ProcessStartInfo { FileName = @"C:\", UseShellExecute = true } );

 

medvedilich said:

protected override void OnStart()
{
            var program = new Process {
                StartInfo = {
                    FileName = "python.exe",
                    WorkingDirectory = @"C:\Users\alan\AppData\Local\Spotware\cTrader\4a28ae902aa17e9068eea37241a33c59\app_4.2.22.8450",
                    Arguments = "d:/программирование/python/test.py"
                }
            };
            program.Start();

}

When I run this code, there is a message in the log: 'Crashed in OnStart with Win32Exception: An error occurred trying to start process 'python.exe' with working directory 'C:\Users\alan\AppData\Local\Spotware\cTrader\4a28ae902aa17e9068eea37241a33c59\app_4.2.22.8450'. Unknown error (0x2)'

However, it works in Visual Studio in console app, and python file executes.

 


@winsonet