Finding PID of external process called from MATLAB

Hello All,
I call an external process(.exe) from matlab on windows machine through the script using 'system()'
is their any way to findout the PID of the above called process (note : the same process may also be active apart from matlab called once i.e several instances of that application may already be active , but i am interested to only find out the PID of the process called from matlab) ?

답변 (1개)

Walter Roberson
Walter Roberson 2019년 12월 24일

1 개 추천

Instead of using system(), use .NET to start the process
After that, the process ID will be the Id property of the object.

댓글 수: 4

i have used .NET to start the process,but i am still confused how to know the PID.
any demo code would be helpful
thank you in advance
proc = System.Diagnostics.Process();
proc.StartInfo.FileName = 'energyPLAN.exe';
proc.StartInfo.Arguments = 'energyPlan Data\Data\Portugal_2050_tmp.txt';
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.RedirectStandardInput = true;
proc.Start();
pid = proc.Id();
i am getting the below error
Message: The system cannot find the file specified
Source: System
HelpLink:
This is demo code, like you had asked for. You would need to change FileName to match the path to the exe you want to run, and need to change Arguments to any command line arguments needed.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 MATLAB Support Package for Arduino Hardware에 대해 자세히 알아보기

태그

질문:

2019년 12월 24일

댓글:

2019년 12월 25일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by