Opening MPLABX by double clicking on a project file


When you create a project in MPLABX, none of the files that it creates can be used to open MPLABX. Instead, you have to open MPLABX and then open your project by navigating to it (or leave it open in MPLABX when you close the IDE). I have devised a means to open a project in MPLABX by double clicking on a file.
(MPLABX is based on Netbeans version 6, so I imagine something similar could be done to open Netbeans projects. I'm not familiar with the native Netbeans or other types of Netbeans projects, so I'm just guessing here.)
Basically, it works by saving a script that opens MPLABX with a command line, sending it the project's folder path. I rename the script file with extension ".mplabx" and then set up an association that calls the scripting engine for that type of file. I chose to use VBScript as the language for this.
  1. Create a VBScript file. See attachment for source code. It looks for a folder that ends with ".X", in the same directory as the script file. If more than one is found, it looks for a folder with a similar name as the script file, e.g. MyProject.mplabx will open the project in the folder named MyProject.X.
  2. Rename the script file to ".mplabx".
  3. Add an association to the Windows registry for opening .mplabx as a file that can be run by the Windows scripting host. The most important part here is the HKCR\MPLABXFile\ScriptEngine\(Default Value) needs to be set to "VBScript". The attached registry file sets up this association and sets the icon for the new file type. This reg file is based on the built-in .vbs and VBSFile keys.
  4. Add an environment variable named "MPLABX" which points to the installation location of MPLABX. The command sent by the script uses that variable to determine the location, like this: "%MPLABX%\mplab_ide\bin\mplab_ide.exe"