Matlab GUI freezes when it uses System command

20 views (last 30 days)
Hello all,
I hope this finds you well,
My matlab GUI launches another whenever it is opened. using this code:
command = 'C:\Program Files (x86)\Texas Instruments\High Speed Data Converter Pro\High Speed Data Converter Pro.exe' ;
system(command);
It launches the other GUI correctly. However, it freezes until i press Ctrl+c.
It says that :
Operation terminated by user during dos (line 66)
In app1/startupFcn (line 78)system(command);
Any suggestions ?
Thank you,
Best regards,

Accepted Answer

Walter Roberson
Walter Roberson on 1 Sep 2018
In MS Windows, there are two kinds of applications: "console" applications and "graphics applications" (I might not be using the right terminology.)
"console" applications run in a DOS shell and have access to standard input and standard output, so any message they send to standard output will stay around in the DOS shell even after the program itself terminates. They can do graphics. For the purpose of system(), they are not considered to have terminated until the DOS shell exits.
"graphics" applications disconnect from the program that launched them, and open a GUI. For the purpose of system() they are considered to have terminated as soon as they finish disconnecting from the program that launched them.
If it happens that the program you are invoking is coded as a console application, then system() will not return to continue MATLAB processing until the program is exited. This is normal behaviour for system() for that class of program.
Depending on exactly how the program interacts with the user and its environment, you might be able to work around this by simply adding the character & to the end of the command string. For example,
command = '"C:\Program Files (x86)\Texas Instruments\High Speed Data Converter Pro\High Speed Data Converter Pro.exe" &' ;

More Answers (0)

Categories

Find more on Performance and Memory in Help Center and File Exchange

Tags

Products


Release

R2018a

Community Treasure Hunt

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

Start Hunting!