Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [status, result] = system('EX.exe');
- [status, result] = system('start EX.exe');
- setappdata(0, 'running', 1);
- tim = timer(...
- 'StartDelay', 2, ...
- 'TimerFcn', 'while getappdata(0, ''running''), fprintf(''timer running ...n''); pause(1); end' ...
- );
- fprintf('Starting timer.n');
- start(tim);
- fprintf('Calling external program ...n');
- [s,r] = system('EX.exe');
- fprintf('External program returned %d.n', s); % <-- This is never reached.
- setappdata(0, 'running', 0);
- fprintf('Stopping timer.n');
- stop(tim);
- delete(tim);
- >> runtime = java.lang.Runtime.getRuntime();
- >> process = runtime.exec('program arg1 arg2');
- >> ...
- >>
- >> % when you want to collect results.
- >> process.waitFor(); % block until program returns.
- >> process.exitValue(); % fetch process return code.
- >>
- >> % or, if you need to abandon the work,
- >> process.destroy(); % violently kill process
Add Comment
Please, Sign In to add comment