MATLAB Answers

Why is a new instance of MATLAB opened when I double-click on a MATLAB file in Windows Explorer even if I have one instance of MATLAB already open on my Windows 7 machine?

Asked by MathWorks Support Team on 18 Apr 2013
Latest activity Commented on by Ranjan
on 14 Nov 2014

I have full administrative privileges on my Windows 7 machine and I run MATLAB as an administrator. I then open a Windows Explorer and double-click on a MATLAB file. I expect the MATLAB file to open in the existing instance of MATLAB, instead another instance of MATLAB is launched, and the MATLAB file opens there in the Editor. If I double-click on another MATLAB file in Windows Explorer, it opens in Editor in the second instance of MATLAB. However, if I close the second instance of MATLAB and then double-click on a MATLAB file in Windows Explorer it will open another MATLAB instance.

I am running MATLAB as an administrator because otherwise I cannot save path from File->Set Path->Save menu. I have User Control Access (UAC) turned on and I cannot turn it off because of security considerations.

  1 Comment

on 14 Nov 2014

same problem on the student version - click on an m file - a whole new Matlab instance starts up - which takes forever- when in fact matlab is already running

2 Answers

Answer by MathWorks Support Team on 18 Apr 2013
 Accepted answer

This behavior may have one of several causes:

A. This may be a consequence of the security settings on Windows 7. When you run MATLAB as an administrator and then try to open a MATLAB file from Windows Explorer, you are not a privileged user as far as Windows Explorer is concerned. As a result, MATLAB that is open cannot open this MATLAB file since MATLAB is a program that is run by a privileged user (administrator).

To work around this issue, you can enable writing to the pathdef.m file. The pathdef.m file is located in the directory:


where MATLABROOT is the result of executing the following in the MATLAB command prompt:


To enable writing to pathdef.m:

 1. Open the directory with pathdef.m in the Windows Explorer, right-click on the file and open "Security" tab.
 2.  Click the "Edit" button to modify permissions.
 3.  Select the user or group that should be allowed to write to pathdef.m, i.e., Users.
 4.  Check the "Write" check box and click "Apply"

If you have previously set MATLAB to be run as an administrator, change it to run it as an ordinary user. You will be now able to save path to the pathdef.m file and each time you click on the MATLAB file, if MATLAB is already open, MATLAB file will be opened in the Editor of the open MATLAB instance.

B. This issue may also arise if you uninstall an earlier release of MATLAB after installing a newer release. The newer release uses a different method to register file associations.

These associations are deleted from the registry when an older release is uninstalled.

In this situation, please uninstall the new release and reinstall it.

  1 Comment

Truc Phan
on 19 Aug 2014

this solution does not work on my Windows 8.1, Matlab R2011a

Answer by Farzaneh
on 20 Aug 2014

I am using Matlab R2012b. I have the exact same problem, i.e. each time I want to open a matlab-related file, a new session of matlab is opened, instead of opening that file in the already opened matlab session. I have set full control permission to pathdef.m file. No success. Please help.


Image Analyst
on 21 Aug 2014

What about permissions to the folders and subfolders that contain pathdef.m? Do those also have full control?

Alex Jose
on 16 Oct 2014

If you are a support customer, you can submit your question to MathWorks support via the 'My Service Requests' page which is accessible at

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply today