Quantcast
Channel: Programming – Xinyustudio
Viewing all articles
Browse latest Browse all 284

C#: How to get installed Matlab paths and versions

$
0
0

In a recent project, I need get the installed Matlab’s executable path and their versions, and I know that users might not install Matlab in default “C:\Program files\MathWorks\…”.

The first solution that comes to my mind is to use the registry to find the desired results, as also shown in my previous post : How to get SolidWork exe path programmatically. It turns out that it is not as easy as it should be. Then I found another approach that really works well.

Every time when you install a Matlab version, Matlab installer will add the executable path to the system path, as shown below: (The snapshots come from my another freeware SysPathEditor)

image

So it is now easy to do the job:

  1. Get the system path
  2. Loop all items in the system path, and search with keywords with “Matlab” and “Bin”
  3. Return the ouptut.

Running the 7-line code snippet above, oh yeah~~~

image

Download the 7-line source code and exe file. Happy coding!


Filed under: Dotnet/C# Tagged: Matlab path; COMSOL; change; update; with Matlab

Viewing all articles
Browse latest Browse all 284

Trending Articles