C#: How to get installed Matlab paths and versions

21 Sep

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)


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~~~


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

Leave a comment

Posted by on September 21, 2012 in Dotnet/C#



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: