Click here to Skip to main content
11,928,754 members (52,932 online)
Rate this:
Please Sign up or sign in to vote.
See more: C# VB Windows VB.NET service
Windows services run in session 0, i have a code that i need to run as a user in session 1
from the windows services. Please feel free to guide as i am new on this.
Posted 27-Mar-13 22:29pm
Edited 1-Apr-13 22:01pm
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

Analyse the requirements again. Do you really need to run "code" of the service from a user session? Surely not.
You need an application running in the context of the user which communicates with the service by e.g. .Net Remoting (old) or WCF, ...
muneebalikiyani 28-Mar-13 5:02am
Yes, your are right on that i want to run "code" of service from a user session.
Ian A Davidson 28-Mar-13 6:10am
Voted 5. Having a user application that communicates with the service is the only solution I can think of as well. WCF seems to be the current standard, as you mentioned.
Rate this: bad
Please Sign up or sign in to vote.

Solution 3

You can't do that. It's considered a security risk and Microsoft has taken steps to prevent you from doing what you want to do.
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

1) Goooooooggggggggllllleeeeeee!!!!!!
2) Have a look here: Subverting Vista UAC in Both 32 and 64 bit Architectures[^]
3) you can even call psexec with proper parameters if you don't want to bother yourself with the windows api
muneebalikiyani 28-Mar-13 3:51am
It requires an .exe file to run from service , i want to run code (not a program ) from windows service.
Zoltán Zörgő 28-Mar-13 5:21am
You wrote yourself, even if you deleted it: that you want to run a "user created process".
You can not spit a process between sessions. Forget it. A process is bound to a session. As I suggested, you can start only a process in a session. Or you can change authentication context a thread, bot not the session. But it makes no sense not to build a separate executable for that task since you can have several kind of IPC to communicate with your service.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web03 | 2.8.151126.1 | Last Updated 2 Apr 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100