Why can't I save my MATLAB path on Windows with User Account Control (UAC) on?
195 views (last 30 days)
MathWorks Support Team on 10 Sep 2012
I am trying to save the MATLAB path on Windows with the User Account Control (UAC) set to "on".
MATLAB is installed in a directory protected by UAC (e.g., C:\Program Files).
If try to execute the function SAVEPATH, my path is not saved and I receive the following warning:
Warning: Unable to save path to file 'C:\Program Files\MATLAB\R2021b\toolbox\local\pathdef.m'.
You can save your path to a different location by calling SAVEPATH with an input argument that
specifies the full path. For MATLAB to use that path in future sessions, save the path to
''pathdef.m'' in your MATLAB startup folder.
If I try to save the MATLAB path from PATHTOOL ('Set Path' dialog) I get the message:
MATLAB cannot save changes to the path.
The path file, pathdef.m, might be read-only
or might be in a directory for which you do not
have write access.
You can save pathdef.m to a different location,
In order for MATLAB to user the pathdef.m
in future sessions, you need to save it in your
MATLAB startup directory (the directory from
which you start MATLAB).
Would you like to save pathdef.m to another location?
I have full administrative privileges on this computer.
MathWorks Support Team on 13 Feb 2022
Edited: MathWorks Support Team on 12 Mar 2022
If MATLAB is installed in the default directory (C:\Program Files\...) with UAC enabled, write access to "pathdef.m" will be blocked.
There are three ways to work around this issue:
1. Temporarily turn UAC off by right-clicking on the MATLAB icon, and selecting "Run as Administrator", or
2. Permanently turn UAC off through the Windows Control Panel, or
3. Install MATLAB outside of the "C:\Program Files" folder.
If you are encountering this issue when using the 'pathtool' dialog, note that you can still make temporary changes to the MATLAB path which persist only for your current session. You can do this by adding a folder with the 'pathtool' and then closing the window without clicking "Save", or by using the 'addpath' function:
For more information on the UAC, which was introduced with Windows Vista, see the following Microsoft article:
More Answers (3)
Ed Callway on 4 Mar 2020
Edited: Ed Callway on 4 Mar 2020
It's 2020, and matlab still can't save the path when you hit "save path" in an actual set-the-path menu?! Yet dozens of other matlab preferences save perfectly as do EVERY OTHER PREFERENCE IN EVERY OTHER WINDOWS PROGRAM EVER. Above is the worst "my first Fisher Price program" set of answers ever:
- Turn off UAC 'cause I love viruses
- Install outside of programs directory because I want to be different than EVERY OTHER PROGRAM ON EARTH
- Split the user defined paths from the core paths needed for boot up
- Put user defined stuff in the USER directory like every other program on earth
Why am I so angry? I lose 10 min a day on this ridiculous issue. Money back please.
yunhui zhou on 19 Mar 2020
Edited: yunhui zhou on 19 Mar 2020
Please note the following words in error message: " You can save pathdef.m to a different location, In order for MATLAB to user the pathdef.m in future sessions, you need to save it in your MATLAB startup directory (the directory from which you start MATLAB). Would you like to save pathdef.m to another location?".
Just copy and save pathdef.m to your user directory (for example "C:\Users\<Your_Name>\Documents\MATLAB") and you can save your path without messing the MATLAB path for other users of your computer.
Tarek Bekir on 17 Mar 2019
- Go to C:\Program Files\MATLAB\R2017b\bin\ or wherever the matlab is installed then find the matlab.exe file.
- Right click on matlab.exe , and select properties.
- Select compatibility tab.
- Tick the Box : Run this program in compatibility mode for: and select for example windowsXP sp3
- Tick the box at the bottom "Run this program as an administrator". (This is the important option)
- Restart matlab and enjoy!
Hope this might help.