MATLAB: Does MATLAB fail to start after I have called a MATLAB Engine application from within MATLAB 6.5.1 (R13SP1)

automationcomdeleteengineMATLABprefdirsecondsessionstartup

From MATLAB, I spawn an external process using the bang (!) operator (or the UNIX, DOS, or SYSTEM command). That external process is a MATLAB Engine executable. This causes a second instance of MATLAB to start. After I have exited both MATLAB sessions, I am unable to restart MATLAB. It crashes on startup. The only way I am able to start MATLAB is to remove all of the files in my MATLAB preferences directory. Unfortunately, this also deletes all of my customizations to the MATLAB Desktop.

Best Answer

In order to work around this limitation, consider the following workaround:
Create a finish.m file which contains the following commands:
cd(prefdir); %%move to the preferences directory
delete('*'); %%delete all of the files
This code deletes all of the files in the user's preferences directory. However, when MATLAB exits (after executing finish.m) it rewrites the files thus creating valid copies again for the next session.