Automatically detect the trust level of the application before attemptin...

...g to get the environment variables.