MATLAB: Does MATLAB crash on Windows with an error referring to libmwservices.dll

MATLAB

When I start MATLAB, I receive the following error:
MATLAB has encountered a problem and needs to close. We are sorry for the inconvenience.
The details of the crash reveal: ERROR: AppName: matlab.exe AppVer: 1.0.0.1 ModName: libmwservices.dll ModVer: 1.0.0.1 Offset: 00093743

Best Answer

This error can occur if there are unnecessary spaces or other formatting errors in the environment variable LM_LICENSE_FILE. To verify this variable is incorrect, you can point a MATLAB shortcut directly to your license file, or network license manager.
To do this locate your shortcut to MATLAB. If you do not have a shortcut to, navigate to $MATLAB\bin\win32 (where $MATLAB is your MATLAB installation directory). Locate 'MATLAB.exe' and right click on the file. Select 'Create Shortcut and place the newly created shortcut in a location of your choice.
Once you have a MATLAB shortcut, perform the following steps:
1) Right click on the shortcut to MATLAB that you are using (most likely on the desktop)
2) In the 'Target' field add a space at the end, a '-c', another space, and the path to your license.dat file (if you are not using a license.dat, you can point to the license manager for MATLAB. This is done by pointing the the port number and at the hostname of the machine)
ex: "C:\Program Files\MATLAB\R2006a\bin\win32\MATLAB.exe" -c "C:\Program Files\MATLAB\R2006a\bin\win32\license.dat"
or "C:\Program Files\MATLAB\R2006a\bin\win32\MATLAB.exe" -c 27000@my-host
The default location for the license.dat is $MATLAB\bin\win32 for R2007b and earlier as shown in the example. For R2008a and later the path is $MATLAB\licenses. If MATLAB launches, there is a problem with this variable and you must fix the error for MATLAB to start normally.
To edit your environment variables, open the Windows 'Control Panel' and open the 'System' application. Navigate to the Advanced tab and select Environment Variables. Highlight the System variable labeled LM_LICENSE_FILE and click 'Edit'. Fix the formatting in the variable value. MATLAB should now launch.
If you do not have an LM_LICENSE_FILE set or you are still having this issue, check the computer's Hosts file to make sure it exists and is correct. This error may occur if the computer has no hosts file, as well as the other essential
networking files located in c:\windows\system32\drivers\etc
(lmhosts.sam; networks; protocol; and services).