Click here to Skip to main content
16,016,759 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more: , +
I have an application that works in the background, so I've made it as a service application. But the problem is that my application requires administrative rights.
And I'm making this application as a "must-be-running-all-times" (It is for computers in my school's computers, which are for students, and if it is not running, students will be free to do whatever they want). So now you know why I want my service application to run as administrator. Ok now to the point:
If I just tell Windows to run it as administrator in the manifest, it'll show a popup asking whether to run it or not. And some students might click on no, that's the problem, I don't want that popup to show. And for those who say it's not possible, I have an application installed in my computer which doesn't even show the popup (it runs at startup, or maybe before that), and I'm sure that that application is working as an administrator. My question if you missed it:
How do I make my service application start as administrator at startup?

I'll appreciate any help.
Posted
Comments
F-ES Sitecore 11-Nov-15 8:39am    
Is this a Windows Service? If so set the service user to an admin one and set it to start automatically.
Nafees Hassan 11-Nov-15 10:17am    
But it is not necessary that everyone's administrator username is admin? and which option is it that makes it start automatically, stAuto?
F-ES Sitecore 11-Nov-15 10:49am    
Part of the service config is the account the service runs under. Have that account be an admin account, that way it doesn't who is logged into the desktop, your service always runs as an admin. Also part of the service config is the start mode, one possible option is start automatically.
Nafees Hassan 11-Nov-15 12:01pm    
I've tried making user accounts using Delphi, but that requires JEDI, and I don't know why JEDI doesn't work with my Delphi XE2.

1 solution

You question is confusing. You say you wrote a Service application. Service apps start without anyone logging into the machine. They start when Windows starts, not when someone logs in. There is NEVER an interface that appears when someone logs in asking whether to run it as an administrator or not.

You apparently didn't write a service application but a normal Windows Forms application that you're starting out of the registry Run key. This is NOT a service application. Applications running out of the Run key will ALWAYS run as the user that logged in. If that user does not have administrative permissions, your application will fail to launch.

You need to rewrite this application as an actual service application in order for this to work. You can not have any user interface at all and no interaction with logged in users desktop. Service applications run under their own separate desktop that the user never sees.
 
Share this answer
 
Comments
Nafees Hassan 12-Nov-15 5:58am    
My application is a service application (TService). And the desktop in which the service runs, is it a administrator one or just a limited one? and one more thing, even in the service application, I am able to use ShowMessage, InputBox etc.
Dave Kreskowiak 12-Nov-15 9:46am    
You absolutely can NOT have any user interface in a service application. The second you put up anything the user has to interact with your service will hang forever waiting for input that will never come.

Services, by default, run as Local System. It's kind of like an admin account. This is setup in the properties of the service in the Services management app.
Nafees Hassan 12-Nov-15 9:55am    
Thanks for helping me clear my misunderstandings. It turns out that I was testing services using f9, which runs it just like a normal program, not like a service, that is why I was able to use the Dialogs. Just one last question:
Does the "Local System" has rights to modify registry?
Dave Kreskowiak 12-Nov-15 10:23am    
Yes
Nafees Hassan 19-Dec-15 8:56am    
Oops! sorry, forgot to mark it as solved, did it now.

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