0

Is there a way to wait until a java or .NET process exits apart from using pause()? Using an example from this answer: https://stackoverflow.com/a/8932157/3850072

while true
    if proc.HasExited
        fprintf('\nProcess exited with status %d\n', proc.ExitCode);
        break
    end
    fprintf('.');
    pause(.1);
end

I was trying to use proc.StartInfo.Arguments = '\wait'; or even proc.WaitForExit(); but these attempts didn't work. I can achieve what I want by using the system command instead, but in that case the output window of the console doesn't get displayed.

2
  • Whats about system('start /wait ping 127.0.0.1')? Uses system command and opens a new window Commented Feb 24, 2015 at 14:15
  • I should clarify: I can either make system wait by calling status = system('C:\SIMPACKv8.9\spck.bat') or let the output be shown by status = system('C:\SIMPACKv8.9\spck.bat &'), but in the second case Matlab continues, it doesn't wait for the process to be finished. ping 127.0.0.1 didn't seem to do anything... Commented Feb 24, 2015 at 14:52

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.