Click here to Skip to main content
15,896,557 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,

Is it possible to run a function/thread on a different user session from a service as done with CreateProcessAsUser without the need to put a seperate .exe file on the disk before?

Thanks
Posted
Comments
#realJSOP 3-Mar-11 7:53am    
I'm not sure I understand what you want, or why you would want to do this.
knaf 3-Mar-11 8:03am    
I want to run a process which interacts with the desktop from my service, but I don't want to put a seperate exe file which the user could run accidentally if the service didn't run it.

1 solution

I want to run a process which interacts with the desktop from my service, but I don't want to put a seperate exe file which the user could run accidentally if the service didn't run it.

Then maybe create the executable you want to run code as a console or something that requires valid command line parameters sent to it. If it doesn't retrieve valid parameters, it exits immediately

This way, if the user starts it it'll just exit. But when your service starts it & provides the required parameter, it will run.

That's the easy way, imo.
 
Share this answer
 
Comments
knaf 3-Mar-11 8:57am    
thanks.
It's seems like a good idea, but a little problematic if the user will try to hack a it somehow. isn't there an official way?
Sergey Alexandrovich Kryukov 3-Mar-11 12:41pm    
There is not way to define "official"; and the hack can be done in many ways, not just this one.
"Officially" Windows Services are designed for completely different purposes, so your requirement is flawed in first place.
--SA
Sergey Alexandrovich Kryukov 3-Mar-11 12:43pm    
Dylan, I am not sure your method will work; did you try? I would say the whole OP's idea is wrong. What would be the purpose if such abuse?

(Khaf, could you answer?)

--SA
Dylan Morley 4-Mar-11 4:52am    
I agree...while I approve of attention to security, seems like overkill in this case. Can't really see the point.

All my answer will do is stop someone 'accidentially' running it, e.g. double clicking in the explorer window will just cause the program to start and stop immediately, like many other command line tools that require parameters to execute & actually do something.

knaf 3-Mar-11 13:49pm    
Hi,

the service has admin previlegs, so if the service communicates with an external application, if someone will replace that app. with another file, it might be a way to get admin previlegs.

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900