Programmatically Disable a Toolbox

I have an external toolbox (created by me) and I want to disable it (not uninstall it), do some stuff, and then re-enable it.
I have looked through the available methods in matlab.addons.toolbox, but I only see options for installing and uninstalling.
Looking at other ideas, removing the paths would be a way to disable the toolbox, but how do I know (programatically) what paths to remove? Looking in the Add-Ons explorer I can see the paths associated with the toolbox and I have an option to diasble it, but I can't get either of those through the matlab.addons.toolbox API.
I think I either need a way to get the paths for the toolbox, or I need a method that allows me to disable it.
Am I missing something that exists today to do this?

 採用された回答

Cris LaPierre
Cris LaPierre 2024 年 5 月 15 日
移動済み: Cris LaPierre 2024 年 5 月 15 日

0 投票

Does matlab.addons.disableAddon do what you want?

6 件のコメント

the cyclist
the cyclist 2024 年 5 月 15 日
編集済み: Walter Roberson 2024 年 5 月 15 日
@Cris LaPierre, looks like your URL got messed up? My "correction" did, too, when I tried the same way. Here it is without separate name for the link: https://www.mathworks.com/help/matlab/ref/matlab.addons.disableaddon.html
Matt Butts
Matt Butts 2024 年 5 月 15 日
移動済み: Cris LaPierre 2024 年 5 月 15 日
disableAddon is exactly what I wanted. I just never thought to explore up a level, I was stuck at matlab.addons.toolbox.
Thanks!
Cris LaPierre
Cris LaPierre 2024 年 5 月 15 日
Thanks. I've updated it.
DGM
DGM 2024 年 5 月 16 日
Holy smokes I didn't know such a thing was available, but it's been a long time since I looked.
Prior to R2017b, was there a way to do the same?
Cris LaPierre
Cris LaPierre 2024 年 5 月 16 日
I do not know. I assume you picked that release because you noticed on the doc page that this was introduced in R2017b.
DGM
DGM 2024 年 5 月 16 日
Yes. This sort of functionality is something I've looked for before, but I would have been running R2009b, R2012a or R2015b at the time. I still do compatibility checking in older versions.
The addons manager in R2015b doesn't even have an option to enable/disable products in the GUI, so maybe that's part of underlying changes to the addons system.

サインインしてコメントする。

その他の回答 (1 件)

Image Analyst
Image Analyst 2024 年 5 月 15 日

0 投票

Another way is you could remove the toolbox folder(s) from the path with rmpath

3 件のコメント

Matt Butts
Matt Butts 2024 年 5 月 15 日
In order to do that, I need to know what path the toolbox is installed at. I can see that in Add-Ons explorer, but I havent seen the associated paths in any output from the command line add-on methods.
Image Analyst
Image Analyst 2024 年 5 月 15 日
Use the path variable in your code:
mp = path % store the MATLAB path in variable mp.
% Then search it to find and remove the toolbox folders.
% Stick new path back into path
path = savepath(mp)
Finding the folders and deleting them from the variable is probably more complicated than the other solution given to you.
Matt Butts
Matt Butts 2024 年 5 月 15 日
I would be guessing at whether a path belongs to the installed toolbox or not. And I cannot use any known structure about the particular toolbox's paths, because the actual reason I am using this code is to remove old paths from the MATLAB path that point to defunct (old) installations of the same toolbox.
In order to use the remove path method, I would need to know explicitly which paths are there because of the installed toolbox.
As you mentioned though, disableAddon is exactly what I wanted and is far more robust.

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeIntroduction to Installation and Licensing についてさらに検索

製品

リリース

R2023b

質問済み:

2024 年 5 月 15 日

コメント済み:

DGM
2024 年 5 月 16 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by