Running .exe file from MTLAB using system()

조회 수: 33 (최근 30일)
Mehdi
Mehdi 2015년 2월 21일
답변: mehdi rezaei 2017년 2월 15일
Hi everyone,
I use system to run my executable file:
system('myfile.exe')
The problem that I'm facing is that it doesn't go to next line unless I close the GUI (which the exe file opens). The exe file doesn't need an input so all I want is to run the exe file programmatically and move on to the next line without waiting for an action from the user. Can anybody help me please? I'd be grateful.

채택된 답변

Guillaume
Guillaume 2015년 2월 21일
As per the tip section system's help: to execute the operating system command in the background, include the trailing character, &, in the command argument. Therefore:
system('myfile.exe &');
  댓글 수: 3
Image Analyst
Image Analyst 2015년 2월 21일
Medhi's comment again copied here because he keeps putting his comments as "Answers" to his original question instead of replies to Guillaume, even though they're not:
Thank you but I've tried that; it closes the GUI and opens a DOS page. That's not what I want.
Mehdi
Mehdi 2015년 2월 22일
편집: Mehdi 2015년 2월 22일
You're right, it worked! Because I'm using which to find the path of the exe file, I'd made a mistake in the way I should add & to the string. Now it does what you described:
fileexe_path = which ('gravity_app.exe')
system_command_string = [fileexe_path, ' &']
status = system (system_command_string)
Thank you very much for your help.

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

추가 답변 (1개)

mehdi rezaei
mehdi rezaei 2017년 2월 15일
hello I want to run my executable file and it has some button and i want to press one of this button with matlab code. please help me. thank you everyone

카테고리

Help CenterFile Exchange에서 Environment and Settings에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by