#GPPT Closing External Applications with Automatic Logout

David Meego - Click for blog homepageToday I was asked if the GP Power Tools Automatic Logout functionality can be used to automatically logout other external applications, for example: SalesPad For GP from Cavallo.

My initial answer was that it was not possible as the Automatic Logout functionality provided in GP Power Tools is Dexterity based and does not have the ability to affect other applications.

But then I thought about it some more and …

A quick search online confirmed that you can fairly easily use C# code to identify processes running on the machine and then ask them to close gracefully, or if desired you can just kill the process.

After a short amount of development, we have a script that can be used to close any application on a system programmatically. Adding a trigger allows that script to be called when the GP Power Tools Automatic Logout feature asks Microsoft Dynamics GP to exit.

Below is a screenshot of the Project Setup window for the AUTO_LOGOUT project:

Here is a summary of the components of the project:


A trigger which executes before the MBS_Exit_After_Processes Helper Function. This is a global procedure in the GP Power Tools dictionary which is used by both the Automatic Logout feature as well as the Exit After Processes menu option. The script for the trigger will load and execute the AUTO_LOGOUT Runtime Execute Script.

Runtime Execute Script AUTO_LOGOUT

This Runtime Execute Script uses Helper Functions to set memory variables for the process name and whether to kill the process or request it to close. The process name in script is set to Notepad by default but can be changed on your system to whatever application(s) you are wishing to close.

Once the variables have been set, the script will load and execute the AUTO_LOGOUT .Net Execute Script to run the C# code to close the process.

NOTE: Selecting to kill the process will not give an opportunity to save any unsaved changes and should be used with caution.

If desired, you can duplicate the lines in the script to set the variables and call the C# script to close more than one application.

Having this code as a Runtime Execute Script rather than just including it in the Trigger script allows it to be tested without needing to exit GP.

.Net Execute Script AUTO_LOGOUT

This .Net Execute Script using C# calls the System.Diagnostics.Process library to identify the processes with the name passed in as a memory variable and then either closes or kills the process.

Downloading and Installing

Download the example code, import using the Project Setup window (now possible for first time imports with Build 28.8 onwards), or use Configuration Export/Import window (for older builds):

The code will be active on next login or after switching companies, or you can use start the triggers manually from the Project Setup window.

More Information

For more information see:

Hope you like the enhancement added with this version.


This article was originally posted on http://www.winthropdc.com/blog.

Please post feedback or comments

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

WordPress.com Logo

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

Facebook photo

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

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.