How can I start a 32bit MATLAB from a 64bit MATLAB and the other way around through COM in MATLAB R2014b?

1 view (last 30 days)
I like to start a 32bit MATLAB from a 64bit MATLAB through COM and also to start a 32bit MATLAB from a 64bit MATLAB. The MATLABs are all the same version (R2014b). I registered both MATLAB version as COM servers. But when I simply use 
ml = actxserver('matlab.application')
then the 64bit MATLAB starts a 64bit MATLAB and the 32bit MATLAB starts a 32bit MATLAB.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 5 Apr 2021
Edited: MathWorks Support Team on 6 Apr 2021
This is expected behavior and related to the ay applications processing the registry on Windows. 
In order to be able to control the bittedness you would need to start the particular version of MATLAB through the command line with the /MLAutomation flag 
>>system('"C:\Program Files (x86)\MATLAB\R2014b\bin\win32\MATLAB.exe" /MLAutomation')
and then connect to it using 
>>ml = actxGetRunningServer('MATLAB.Application')
You can query the registry to find the installation folders of MATLAB automatically. Since 32bit application do not see the 64bit registry per default you would need to use:
An example would be (only works if 32bit AND 64bit MATLAB of the same version are registered)
CLSID = winqueryreg('HKEY_CLASSES_ROOT','MATLAB.Application\CLSID');
if strcmp(computer('arch'),'win64')
%start 32bit MATLAB from a 64bit MATLAB
ML_pth = winqueryreg('HKEY_CLASSES_ROOT',['Wow6432Node\CLSID\',CLSID,'\LocalServer32']);
else
%start 64bit MATLAB from a 32bit MATLAB
ML_pth = winqueryreg64('HKEY_CLASSES_ROOT',['CLSID\',CLSID,'\LocalServer32']);
end
ML_pth = strrep(ML_pth,'.exe','.exe"');
system(sprintf('"%s &',ML_pth));
%since the above command is non blocking we have to wait a bit until MATLAB is fully started
pause(10);
ml = actxGetRunningServer('MATLAB.Application')

More Answers (0)

Categories

Find more on Startup and Shutdown in Help Center and File Exchange

Products


Release

R2014b

Community Treasure Hunt

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

Start Hunting!