English 中文(简体)
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.





相关问题
Manually implementing high performance algorithms in .NET

As a learning experience I recently tried implementing Quicksort with 3 way partitioning in C#. Apart from needing to add an extra range check on the left/right variables before the recursive call, ...

Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How do I compare two decimals to 10 decimal places?

I m using decimal type (.net), and I want to see if two numbers are equal. But I only want to be accurate to 10 decimal places. For example take these three numbers. I want them all to be equal. 0....

Exception practices when creating a SynchronizationContext?

I m creating an STA version of the SynchronizationContext for use in Windows Workflow 4.0. I m wondering what to do about exceptions when Post-ing callbacks. The SynchronizationContext can be used ...

Show running instance in single instance application

I am building an application with C#. I managed to turn this into a single instance application by checking if the same process is already running. Process[] pname = Process.GetProcessesByName("...

How to combine DataTrigger and EventTrigger?

NOTE I have asked the related question (with an accepted answer): How to combine DataTrigger and Trigger? I think I need to combine an EventTrigger and a DataTrigger to achieve what I m after: when ...

热门标签