Borrar filtros
Borrar filtros

Running .exe file from MTLAB using system() and Wait until the program closes

5 visualizaciones (últimos 30 días)
Hi everyone,
I use system to run my executable file:
system('myfile.exe')
How to determine that the program was closed? I want MATLAB to run the next line after closing the execution program. Thanks

Respuestas (2)

dpb
dpb el 25 de Sept. de 2017
>> help system
system Execute system command and return result.
[status,result] = system('command') calls upon the operating system to
execute the given command. The resulting status and standard output
are returned.
...
continue reading for further details...
  1 comentario
abbas jalilian
abbas jalilian el 17 de Oct. de 2017
Thank you for your answer But my problem has not yet been resolved I've written a program with Processing and when I run it, MATLAB instantly runs the next lines.

Iniciar sesión para comentar.


Joao
Joao el 28 de Sept. de 2017
I have a similar issue, but in my case the variables status / result are not updated when the executable finishes. It seems to me that these variables are in place to indicate the status of the call to the system function not its output! Any further ideas would be much appreciated!
  2 comentarios
Steven Lord
Steven Lord el 28 de Sept. de 2017
You should probably post this as a separate question, not as an answer on another question. If you do post as a separate question please show the exact line of code you use to call your executable, state what you observed when you executed that line of code, and explain what you expected that line of code to do (referencing parts of that code).
dpb
dpb el 28 de Sept. de 2017
The status is command status; whether it was/was not executed w/o error. The result returned is dependent upon the executed command using stdout for whatever output it returns. Also if you use the trailing ampersand '&' when submitting the command the result output is not updated and status is the status on launching the background session, not on completion.
It can be illustrated to work with command that is known to behave using stdin/stdout; not every console program you may try to execute follows those rules--
>> [stat,res]=system('cd') % simple command w/ known output...
stat =
0
res =
C:\ML_R2014b\work
>> [stat,res]=system('cd:') % oopsies, made a typo...
stat =
1
res =
The filename, directory name, or volume label syntax is incorrect.
>>

Iniciar sesión para comentar.

Categorías

Más información sobre Programming en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by