Click here to Skip to main content
16,018,653 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
The context is that I have a window service. This window service is used to start an Applicaion(Gui).
Up to now, the window service has started the application. Since the Application needs to perform some tasks under admin, it needs to start with admin privileges.
However currently my Window Service can only start application(GUI) with non-admin.

So is there any way window service can start Application(GUI) as admin on windows 10?

I have searched many articles on google but still can't find a solution to solve this problem.
Please experts help me with a solution.

Thanks

What I have tried:

Below are 2 of the articles I have researched

Subverting Vista UAC in Both 32 and 64 bit Architectures[^]
windows - CreateProcessAsUser with elevated privileges - Stack Overflow[^]
Posted
Updated 6-Jan-22 19:03pm
v3
Comments
PIEBALDconsult 6-Jan-22 22:46pm    
I don't think so. Essentially a Service can't have a UI.
alex giulio 6-Jan-22 23:25pm    
I have referenced at the link below so that Window Service can start application(GUI):

https://github.com/murrayju/CreateProcessAsUser/blob/master/ProcessExtensions/ProcessExtensions.cs
_Asif_ 7-Jan-22 0:39am    
have you tried setting admin credentials of the stated windows service -> Services -> My Service -> Properties -> Log On Tab?
alex giulio 7-Jan-22 3:34am    
I haven't tried it yet, but if not setting username/password in windows service's logon tab is there any way to do it?
Because I see the windows service is in session 0 that can get the token of the user who is logging in session 1 to interact with the desktop, like starting a GUI. Besides, I see that the logged in user can manipulate to run the GUI as admin.
So I'm not sure if the windows service can get the token of the logged in user and run the app as admin?

1 solution

If the service runs under Admin account, then yes, it can start GUI exe in Admin account
 
Share this answer
 
Comments
alex giulio 7-Jan-22 3:25am    
So if windows service is running under local system, is there any way to do start GUI as admin?

Because I see the windows service is in session 0 that can get the token of the user who is logging in session 1 to interact with the desktop, like starting a GUI. Besides, I see that the logged in user can manipulate to run the GUI as admin.
So I'm not sure if the windows service can get the token of the logged in user and run the app as admin?
steveb 7-Jan-22 9:03am    
You need to use CreateProcessAsUser API. The code that listed in the StackOverflow is not C or C++. I have no idea what language it is.

Also. If you use that call, it will be listed in the exe and the virus softwre can flag it as a virus or malware. If you are trying to administer user machine remotely there are much better tools provided by the Windows OS. Any OS can be administered remotely without implementing intrusive software. But I am no network admin. You need advice of the knowlegable network admin for that.
alex giulio 7-Jan-22 22:02pm    
Thank you for your polite reply!.
I understood what you conveyed.
It seems that using windows service to start GUI with admin rights is not possible.
Right now I'm trying to investigate the direction of using Windows Schedule to do this. Hope this will be resolved soon.

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