Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 815717
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T01:43:42+00:00 2026-05-15T01:43:42+00:00

I installed a PostScript printer driver and have setup REDMON (redmonnt.dll) for redirecting postscript

  • 0

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.

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.

Q: What are the minimum WinAPI calls required to start a program given a username and a sessionid?

Any code examples in C/C++, .NET would be very helpful.

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.

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T01:43:43+00:00Added an answer on May 15, 2026 at 1:43 am

    Look at CreateProcessAsUser.

    Also look at CreateProcessWithLogonW and CreateProcess.

    They are linked from the CreateProcessAsUser

    EDIT In reply to comments by OP.

    Follow advice from this thread.

    I am copying this here verbatim, in case the original link stops working:

    The same code works for us on Vista as
    on XP, etc. The service is running as
    the Local System.

    1. use WTSGetActiveConsoleSessionId to get the ID of the current active
      Windows session at the console (i.e.
      the machine keyboard and display, as
      opposed to WTS sessions).

    2. use WTSQueryUserToken to get the token for that session.

    3. use DuplicateTokenEx(hToken,MAXIMUM_ALLOWED,NULL,SecurityIdentification,TokenPrimary,
      &hTokenDup) to duplicate that token.

    4. use CreateEnvironmentBlock to create an environment that you will be
      passing to the process.

    5. use CreateProcessAsUser with the duplicated token and the created
      environment. Actually, we use
      CreateProcessAsUserW, since the A
      version had some sort of bug on some
      older systems.

    6. Don’t forget to CloseHandle on the various tokens, etc, and to
      DestroyEnvironmentBlock the
      environment.

    Thank you efratian.

    PS. Oh joy of Windows programming, did not do it for quite a while. Now I remember why. The only thing that is close or even worse documented is OpenSSH programming.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 523k
  • Answers 523k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer What exactly are you tring to acheive? If you want… May 16, 2026 at 9:47 pm
  • Editorial Team
    Editorial Team added an answer Use the :last selector or .last() method: $("#lastcomment").click(function () {… May 16, 2026 at 9:47 pm
  • Editorial Team
    Editorial Team added an answer I think this is what you're after: $('#albox .tt_this').closest('.aledmsg').remove(); You… May 16, 2026 at 9:47 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I have some problems with Miktex installed on Windows Vista Business SP1/32 bit. I
I installed VS10 side-by-side with VS9 and created a very simple application using it:
I'm working on a script that needs to set up a Xerox Phaser printer
I have a grid datawindow with a picture in it's background (with dimensions of
I have a website which uses SVG for an interactive client side thingamabob. I
After installed m2eclipse, I received a message saying that Eclipse needs to run in
I installed m2eclipse to build a java project in Eclipse. I imported the project
I installed ibobjects in delphi 2010 to give the components a try, now I
I installed the wrong version of pysvn in my system using the .dmg. I
I installed the current RSpec 2 Beta under Rails 3 RC as mentioned on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.