Redmon's Run As User not loading user's enviroment variables

Posted by catfish on Stack Overflow See other posts from Stack Overflow or by catfish
Published on 2010-05-21T00:13:40Z Indexed on 2010/05/21 0:30 UTC
Read the original article Hit count: 424

I'm attempting to use Redmon http://www.winimage.com/misc/redmon/ to send print jobs to a custom C# application. Redmon "runs" (actually the Print Spooler) as SYSTEM but has an option to Run As User to allow your application to run under the user that printed the job. The problem is that it doesn't appear to load the user's environment. So calling functions like Path.GetTempPath() points to \windows\temp instead of the user's. Also when attempting to run Outlook 2007+ via MAPI calls (to add attachments) it reports form errors due to, I think, the temp folder location.

Is there a way to "reload" a profile or atleast get your environment vars within the Impersonated application? The only ideas I've had so far is to rebuild the vars directly from the registry, but I want to avoid this since it's a hack around (avoiding implementation details and all that). Or making a stub program that Redmon calls which then properly Run As User with full profile the custom application.

Any other items or tricks?

© Stack Overflow or respective owner

Related posts about c#

Related posts about redmon