Close cmd while getting results
8 次查看(过去 30 天)
显示 更早的评论
Hello,
I was tring to run an exe from system in matlab and get the result before it gets stuck.
I tried [status,result]= system('name.exe < input.txt &' )and I did not get the results.
I am trying tic toc but it seems that it is not returning to Matlab from exe....
this is the part of the code.
cmd='xfoilP4.exe < xfoilinput.txt';
if toc(timer1)<waiting
[status,results]=system(cmd);
else
!taskkill -f -im xfoilP4.exe;
end
0 个评论
回答(2 个)
Jan
2021-8-9
What is the purpos of:
if toc(timer1)<waiting
This not a loop and it does not wait until your command in the system() call is running. This is evaluated once before the system command is started. If the taskkill command is triggered, the system command did not run before.
What does "get the result before it gets stuck" mean? When the command does not finish, you do not get any results.
Please explain exactly again, what you want to achieve.
Image Analyst
2021-8-10
Not sure if this is what you want, but if you don't want the CMD window (console window) to show up while you run your .exe, you can use the -e option to mcc when you compile it. It will just show your GUI without the additional console window.
5 个评论
Image Analyst
2021-8-10
Try taskkill.
I don't think you can get anything from the console window before it exits since I believe MATLAB is just spinning it's wheels at that point waiting for the process to end. You might have to have your process write something to disk and have MATLAB open that file when it resumes.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Startup and Shutdown 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!