Object CreateObject("MATLAB.application") used in VBS script have different behaviours on 2 PCs
Show older comments
Hi,
I have a working VBS script that does not give me the same results on 2 different PCs which seems to have the same MATLAB configuration. Here are the order of operations:
I open a Simulink model manually, which launches a desktop MATLAB 2015b (8.6) instance. Then I start my VBS script from Windows explorer. This script first lines are :
Set ml = CreateObject("MATLAB.application")
ml.Execute("test123=1;"))
On PC #1, since I already have an instance of MATLAB running, my object ml is directly connected to this instance and I can see the variable "test123" in my workspace. If no MATLAB.exe process is running and I start the VBS script, I have a new command window instance that opens. That is what I expect.
On PC #2, I just can't connect to my existing MATLAB desktop instance. Instead, a new command window instance is created each time.
Here are the relevant differences between the two PCs :
- PC #1 only has MATLAB 2015b installed and PC #2 has MATLAB 2011, 2014b and 2015b installed. I thought this was the problem so I changed the first line of my script to Set ml = CreateObject("MATLAB.application.8.6") to eliminate that possible problem. No success with that.
- PC #1 is a fresh PC with not a lot of things installed on it and PC #2 has a lot of stuff installed.
Is there something I need to add in my script to differentiate "link to an existing MATLAB instance" from "create a new MATLAB instance" ?
Thanks a lot.
Answers (1)
Alexandre
on 2 Mar 2022
0 votes
Categories
Find more on Use COM Objects in MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!