Tuesday, March 18, 2008

Conditional Loading of Pro/Toolkit Applications

Pro/Toolkit applications often provide great value. However, not every user needs to be running all applications all of the time. Pro/Toolkit provides a few options for the startup of applications, but these options apply to all users. There aren't any options there to give you direct control on a per user basis. This can be accomplished, however, just in a different way, via the config.pro file.

The trick is to use an environment variable for the value of the PROTKDAT option. The syntax (for both unix and windows) would look like this:

PROTKDAT $SOME_TK_APP

For users that need the application, set the environment variable before Pro/Engineer starts to contain the path and file name of the Pro/Toolkit application registry file.

Here are some examples:

Unix C Shell:
setenv SOME_TK_APP /opt/myprogram/protk.dat

Unix Bourne/Bash Shell:
SOME_TK_APP=/opt/myprogram/protk.dat
export SOME_TK_APP

Windows Batch File:
set SOME_TK_APP=N:\apps\myprogram\protk.dat

In WF3 and earlier, when Pro/Engineer reads the config.pro, it will check the value of the environment variable. If the environment variable is not defined, or doesn't contain the path to a Pro/Toolkit registry file, the config.pro option is silently ignored. Otherwise, it reads in the registry file data and starts the application as instructed.

In WF4, things get a little different. If your environment variable is empty or points to a non-existent file, a dialog box will appear that mentions this "problem". Since the only option in the dialog box is an OK button, the dialog box seems rather pointless and and makes for an annoying user experience.

Anyway, to workaround this "bug", simply have the environment variable point to an empty file when the application is not needed. As a result of this, in my Pro/Toolkit app installs, I typically have two Pro/Toolkit registry files. One respresents the "on" state, while the other (the empty file) respresents the "off" state.

As an alternative to an empty file, the "off" state registry file could have the DELAY_START option set to TRUE. This would still allow for the program to be used, but would not start it up when Pro/Engineer starts. This is a little more flexible because otherwise the application is completely unavailable to the user.


Be sure to read my followup article, Pro/Toolkit: Simplifying Your protk.dat File with Environment Variables.

1 comment:

Marc Mettes said...

I added a note about using this technique with WF4. Thanks goes out to PTC Tech Support for reminding me about the WF4 issue.