How to emulate plugins with executables in ESAPI.

João Castelo
3 min readJun 29, 2020
Photo by Luca Bravo on Unsplash


Often we are caught up with an executable script that should work with the context of some patient.

Carlos Anderson came up with a solution to this problem when he created the ESAPI Essentials Package.

However there’s some limitation of the extent of the StandaloneContext library. One would need to perform the same code over and over to launch the executable that should be the first in the folder that you are launching the binary plugin.

If you’re a CITRIX user, you should be used to open a patient to launch an executable. So it will not bother your normal proccess.

Basically this post will be dedicated to fix the issue of running always the first executable in the folder. And pass the ScriptContext via CommandLine arguments to any executable we click with an OpenFileDialog.

This is the pipeline described:


Let`s start a fresh .NET Framework Library solution in Visual Studio called ContextStandalone.

Remember to reference the VMS.TPS libraries.

In the project properties, change to x64 compilation, and to change the project assembly name to ContextStandalone.esapi , this will be important, when you compile the name of the binarty will be ContextStandalone.esapi.dll

Rename the first file, from Class1.cs to Script.cs

Code the following lines into the Script.cs file:

Next, add the CommandLineParser library via NuGet Package Manager to your project.

João Castelo

Radiation Therapy Medical Physicist and Programmer