2008/07/19

Dynamically setting environment variables for a program without a .cmd script?

Say you need to set a few environment variables for program x. You don't want to clutter config.sys with more environment variables, and you don't want to reboot.
You also don't want to use a .cmd script to start the program. You'd like to simply have a normal program object that starts the program with a modified environment.
You may know that Rich Walsh' DragText program gives you, as a free bonus, the enhanced DTProgram class, which enhances your program objects with an "environment" page that does exactly this (among other nice things).
What you probably don't know is that this functionality is not in DragText, but it is in OS/2 (eCS) right out of the box. What DTProgram gives you is a nice user interface for this functionality.
So, how do you use it without DragText?
A post from Paul Ratcliffe in the Warpin-User mailing list sheds light on this:
If you are creating a program object, then you can include the
environment variable(s) as part of the setup string e.g.
CREATEOBJECT="WPProgram|My Program|<WP_DESKTOP>|EXENAME=$(1)\whatever.exe;SET xxx=yyy;OBJECTID=<WP_MYPROGRAM>;"

Obviously you need to customize this for your own title, .EXE name,
object ID, folder location and environment variables.

You will need some rexx skills to make use of this suggestion, but it is indeed really nice to know!

1 comment:

Unknown said...

The sample code from Paul Ratcliff is using Warpin syntax (appropriate for the Warpin list).

The syntax for this is a bit different if you use REXX. So those who want to try this tip using REXX should refer to the REXX documentation to see what the proper syntax is in REXX.