'Run older version of MATLAB in batch file
There are two versions of MATLABs (2007a and 2019a) installed on my computer. The 2019a is installed after 2007a so if you use the following code in batch file:
start matlab -r "xxx.m"
The system will call 2019a instead of 2007a.
I searched online and found that most of people say you can call older version by:
start "C:\Program Files (x86)\MATLAB\2007a\bin\win32\MATLAB.exe" -r "xxx.m"
I tried but it give me this error:

if the batch file doesn't include any command ("-r" etc.), it works just fine. MATLAB can be opened without problems.
What's the mistake I made? How could I call older version and have it run some functions?
My OS: Win7
Solution 1:[1]
Thanks for all of guys who commented under my question. Turned out there are two ways to do this.
- As one of comment said, you just need a pair of "" after start:
start "" "C:\path\MATLAB.exe" -r "xxx.m"
- You actually don't need "start", just use directory is fine:
"C:\path\MATLAB.exe" -r "xxx.m"
Both ways solve the problem. A good lesson to learn for starters.
Solution 2:[2]
I know this post is old. But I was searching for a solution and found one by myself. The best way is to change the order of the windows environment variables. just put the older version over the newer one and you can use the old script.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Siyu Jiang |
| Solution 2 | Walter |
