Execute NONMEM models via the right-click menu (with user specified commands)

Wouldn’t it be nice to have this option when you click on a model file:

It can be quite a hassle to start the execution of your NONMEM models. Luckily, you will now be able to access your favorite NONMEM/PsN functions from the right-click menu!

What we want to achieve is that after clicking the menu item, a user generated batch file will be executed that you can specify yourself with all the functions needed.

Requirements for this to work:

  • Admin privileges on your computer
  • Some knowledge on batch files

Registry settings

In order to make this work, we need to edit some things in the Windows registry. You will need to have an admin account on your computer since some changes in the registry can corrupt the system. Therefore it is always advised to have a back-up ready 🙂

The way to access the registry is by Start –> Search for: regedit.exe

Then, go to the folder HKEY_CLASSES_ROOT –> * –> shell and add a new Key to this folder.

Double click on the (Default) Name and set the Value data with the text you want to see in your menu.


Now, you would already see this option in your right-click menu but nothing happens when you click it. In order to link our new item with some executable, we need to add a command to it.

As a sub-folder to the ‘Execute PsN’ folder in my case, I added a new Key called command in which we specify what happens in the background.

The Data value of the command Key points to the batch file that we will write and gives the argument %1. This argument is the current file that was clicked.

Example: “J:\General\ExecuteModelClick.bat” %1

This will open the ExecuteModelClick.bat file in the General folder.

Batch file

In the batch file, we first need to retrieve the full path (location, file name, extension) of the clicked file by %*. We then extract the filename and extension and set it to a new variable called ‘mdlfile‘. The model will be run using the PsN command: execute %mdlfile%
This batch file can be expanded with diagnostic scripts in R, as was written in a previous post.

SET args=%*
echo "Congratulations! You started a NONMEM model with a single click!"

for %%a in ("%*") do set "mdlfile=%%~na%%~xa"

execute %mdlfile%


Save this text as a .bat file (create a new text document and save as filename.bat) in any location you have write access to and make sure the registry is linked to the right location.


If you are a NONMEM user which has not found a GUI that is right for you (like me), this is the fastest way to run a model and keep control over what is happening behind the scenes. The right-click menu can be further expanded, so you can add one item to create the diagnostics, one to run a VPC, one to run a bootstrap, etc. Good luck!


Leave a Reply

Your email address will not be published. Required fields are marked *