How to run an executable as a system service?
I've got a file and data distribution application written in .NET 2.0 I've written similar to Steam.开发者_开发百科
This application will need to run in Windows 7 and will need to be able to run and install applications that require administrator rights. However the users will not have admin rights.
My thought was to run the application as a Local System Service. I figured by doing this the application could perform admin rights actions (registry edits, launching apps, etc) when the user isn't an admin.
Are my assumptions correct? What steps do I need to take to have this app install as a Local System Service?
An Administrator will be installing the application but it will be run by a user without Administrator rights.
Thanks in advance!
Just running as a service is probably not enough; you can't generally just take an app (especially an interactive one) and throw a switch and make it a service.
The general pattern in this area is to split your app: the UI runs on-demand as usual, with the rights of the user, and there is also a persistent service that runs that the UI communicates with. Generally, this split is done for permissions issues (like yours) or to be able to perform actions even when the UI is closed.
In your case, you might not be able to use the service to launch applications, since the service generally will not have access to the logged-in user's desktop. It also will not have (easy) access to the HKEY_CURRENT_USER hive in the registry, since Local System is a different account than the desktop user.
精彩评论