How do I get the system to run my program in this very special way?

Raymond Chen

A customer registered their program to be run automatically under conditions not important to the story. They found, however, that the program didn’t work because the program was written with an application framework that looks for configuration files in the current directory, but the system wasn’t setting the current directory properly. They couldn’t change the directory in their program because the code that looks for the configuration file is in the framework, and it runs before any of their code does.

Oh, and I forgot to mention that mention that the FIZZBIN environment variable needs to be set to KRONK, except on Tuesdays, in which case it needs to be SHRONK. Except at night.

Okay, maybe the customer’s requirements weren’t that weird, but you get the idea.

You can’t get the system to do all these things for you, but you don’t have to.

Write a helper program and register the helper with the system. The helper program sets the current directory, sets the FIZZBIN environment variable, does all the fancy preliminary nonsense your precious program requires, and then launches the real program.

Bingo, your current directory, environment variable, and favorite teddy bear are all set up waiting for you.