Re: Spawning a Program From a Serivce Under Terminal Services?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Try using CreateProcessAsUser. You'll want to first call
SetTokenInformation(Token, TokenSessionId, &SessionId, sizeof(DWORD)) on the
token first to specify which terminal session the process should run as.

Note that you will need SeTcbPrivilege to be enabled for the thread that
calls SetTokenInformation for TokenSessionId.

Alternatively, you could use WTSQueryUserToken to retrieve a token handle
for the interactive user on a particular terminal session and pass that
directly to CreateProcessAsUser. This call also requires SeTcbPrivilege.

"David White" <whitedavidp@xxxxxxxxxxx> wrote in message
news:OY2x6R94FHA.1184@xxxxxxxxxxxxxxxxxxxxxxx
>I have a service process running on Win2003 with TS. It waits for
>connections to a Virtual Serial Port which it has created and is servicing.
>When a communications program opens the virtual serial port, I want me
>service to be able to start a program on the desktop of the user who's
>communications program opened the port. This program simply queries the
>user for some info and displays some responses to/from the service (perhaps
>via a pipe).
>
> At this point, I am able to discern the process which holds the comm port
> open (see previous posts). From this process, I can get the SessionId
> established by that user.
>
> So what is involved in starting a program and having it run in that
> session/display on that user's desktop? It looks as if the startup info
> structure passed to CreateProcess can hold a desktop pointer. Could it be
> as easy as supplying this information? If not, can anyone provide a tip on
> how I can accomplish this given the info I have?
>
> Thanks,
>
> David


.



Relevant Pages

  • Re: Spawning a Program From a Serivce Under Terminal Services?
    ... You can use CreateProcessAsUser or SHCreateProcessAsUserW to do this. ... >connections to a Virtual Serial Port which it has created and is servicing. ... >When a communications program opens the virtual serial port, ... I can get the SessionId established for that ...
    (microsoft.public.windows.terminal_services)
  • Re: Spawning a Program From a Serivce Under Terminal Services?
    ... SetTokenInformation(Token, TokenSessionId, &SessionId, sizeof(DWORD)) on the token first to specify which terminal session the process should run as. ... Note that you will need SeTcbPrivilege to be enabled for the thread that calls SetTokenInformation for TokenSessionId. ... you could use WTSQueryUserToken to retrieve a token handle for the interactive user on a particular terminal session and pass that directly to CreateProcessAsUser. ... When a communications program opens the virtual serial port, I want me service to be able to start a program on the desktop of the user who's communications program opened the port. ...
    (microsoft.public.win32.programmer.kernel)
  • (GDI Call) EnumDisplayDevices Failing for WTS Api
    ... The service thread that is calling CreateProcessAsUser ... null promptly on first call if sessionID is not Zero... ... zero at first shot if sessionID!=0. ...
    (microsoft.public.platformsdk.security)
  • Spawning a Program From a Serivce Under Terminal Services?
    ... When a communications program opens the virtual serial port, I want me service to be able to start a program on the desktop of the user who's communications program opened the port. ... I can get the SessionId established by that user. ...
    (microsoft.public.win32.programmer.kernel)
  • Spawning a Program From a Serivce Under Terminal Services?
    ... When a communications program opens the virtual serial port, I want my service to be able to start a program on the desktop of the user who's communications program opened the port. ... I can get the SessionId established for that user. ...
    (microsoft.public.windows.terminal_services)