comserver - Register, unregister, or query MATLAB COM server - MATLAB (original) (raw)

Register, unregister, or query MATLAB COM server

Syntax

Description

comserver([action](#mw%5F5d37ffed-743f-4eb2-ad3d-5354751abc8a)) registers or unregisters MATLAB® as a COM server in your user account without the need for administrative privileges. This syntax is equivalent to:

comserver('register','User','current') comserver('unregister','User','current')

example

comserver([action](#mw%5F5d37ffed-743f-4eb2-ad3d-5354751abc8a),'User','all') registers or unregisters MATLAB for all users. To use this syntax, you must run MATLAB as an administrator.

example

comserver('query') displays installation paths of the registered MATLAB COM servers.

example

s = comserver('query') returns a structure with character vector fields:

Examples

collapse all

Start MATLAB R2020a and type:

You must have administrator privileges to register MATLAB as a COM server for all users.

Start MATLAB with the option. Based on your User Account Control (UAC) settings, you might need to right-click the Windows® Command Prompt or the MATLAB icon to select .

Once MATLAB is running, register MATLAB for all users:

comserver('register','User','all')

Suppose that your system has MATLAB R2019b and R2020a and your administrator registered R2019b as a COM server for all users.

You want to use MATLAB R2020a with a VBA application. Start MATLAB R2020a version and type:

Verify the MATLAB version registered for your account.

     User: 'C:\Program Files\MATLAB\R2020a\bin\win64\MATLAB.exe'

Administrator: 'C:\Program Files\MATLAB\R2019b\bin\win64\MATLAB.exe'

MATLAB displays the installation paths of the registered versions. The path forUser is the MATLAB R2020a installation, so when you start your VBA application, it communicates with MATLAB R2020a.

If you start your VBA application using , then the application uses MATLAB R2019b.

Input Arguments

collapse all

Registration action, specified as one of these values.

'register' Register this MATLAB as a COM server. This action replaces the previous registration, if any.
'unregister' Unregister MATLAB as a COM server.If you want to use the MATLAB registered by the administrator for all users, call:comserver('unregister','User','current')If you are an administrator and you want to change the COM server for all users, there is no need to unregister. Start the version of MATLAB you want to register and call:comserver('register','User','all')If you want to remove the MATLAB registered as a COM server for all users, call this statement. Any MATLAB registered for individual user accounts is unaffected.comserver('unregister','User','all')

Data Types: char | string

Alternative Functionality

For users with administrative privileges, you can register and unregister MATLAB for all users from the Windows Command Prompt. For more information, see matlab (Windows). If you have multiple versions of MATLAB installed on your computer, the best practice is to run thematlab command from the matlabroot folder. To register MATLAB for all users, type:

matlab -batch "comserver('register','User','all')"

To unregister MATLAB for all users, type:

matlab -batch "comserver('unregister','User','all')"

Note

The comserver function is available for MATLAB R2020a and later. To register previous versions of MATLAB, type:

To unregister, type:

Version History

Introduced in R2020a