Skip to content

Commit

Permalink
more robust restart script
Browse files Browse the repository at this point in the history
  • Loading branch information
tholden committed Jul 10, 2016
1 parent 141f732 commit 7ccee3b
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions Core/setup/RestartMatlab.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,15 @@ function RestartMatlab( OriginalPath, CurrentFolder, InputFileName, varargin )
error( 'dynareOBC:RestartMATLAB', 'Please manually restart MATLAB.' );
end

system( [ 'start matlab.exe -sd "' CurrentFolder '" -r "try;matlabrc;catch;end;try;startup;catch;end; cd( ''' CurrentFolder ''' ); path( ''' OriginalPath ''' ); dynareOBC ' InputFileName ' ' strjoin( varargin ) '"' ] );
system( [ 'taskkill /f /t /pid ' num2str( feature( 'getpid' ) ) ] );
try
StartUpScript = fopen( [ CurrentFolder '/DynareOBCStartUpScriptPleaseDelete.m' ], 'w' );
fprintf( StartUpScript, 'try;\nmatlabrc;\ncatch;\nend;\ntry;\nstartup;\ncatch;\nend;\ncd( ''%s'' );\npath( ''%s'' );\ndynareOBC %s %s\n', CurrentFolder, OriginalPath, InputFileName, strjoin( varargin ) );
fclose( StartUpScript );
system( [ 'start matlab.exe -sd "' CurrentFolder '" -r "cd( ''' CurrentFolder ''' );DynareOBCStartUpScriptPleaseDelete;delete DynareOBCStartUpScriptPleaseDelete;"' ] );
system( [ 'taskkill /f /t /pid ' num2str( feature( 'getpid' ) ) ] );
catch
error( 'dynareOBC:RestartMATLAB', 'Please manually restart MATLAB.' );
end

else

Expand Down

0 comments on commit 7ccee3b

Please sign in to comment.