Running .exe file from MTLAB using system()

161 views (last 30 days)
Hi everyone,
I use system to run my executable file:
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.

Accepted Answer

Guillaume on 21 Feb 2015
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 &');
Mehdi on 22 Feb 2015
Edited: Mehdi on 22 Feb 2015
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.

Sign in to comment.

More Answers (1)

mehdi rezaei
mehdi rezaei on 15 Feb 2017
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


Find more on Environment and Settings in Help Center and File Exchange


Community Treasure Hunt

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

Start Hunting!

Translated by