title: WinAPI C - RunAsUser from REDMON_USER and REDMON_SESSIONID
body: <p>I installed a PostScript printer driver and have setup REDMON (redmonnt.dll) for redirecting postscript output to my program.  In my rather simple c program I capture the data from STDIN and I am able to successfully save it into a .ps file.  The file looks OK.</p>
  
  <p>However, I want to start gsview.exe for viewing the file.  If I call ShellExecute it fails in Windows 7 because of permission issues.  It seems that my program is called under a different user account (LOCAL SERVICE).  So I am looking for a way to run gsview.exe under a specific username (the user who initiated the print job) which is available to the program in a variable called REDMON_USER along with the SESSIONID as well.</p>
  
  <p><strong>Q:</strong> What are the minimum WinAPI calls required to start a program given a username and a sessionid?</p>
  
  <p>Any code examples in C/C++, .NET would be very helpful.</p>
  
  <p>EDIT: What I am trying accomplish is something very similar to redrunee (from redmonee).  I don't want to use redrunee because it opens about a console window for a brief moment.</p>
  
  <p>Note:
  1) The program is called by the printer service as [LOCAL SERVICE] account.
  2) The first parameter Username (REDMON_USER), in effect, points to the user currently looking at the screen</p>