Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Controlling a service from an assembly

Status
Not open for further replies.

RexHeadlong

Programmer
Apr 10, 2002
35
US
Hi,
I've seen similar posts, but as yet no viable solution, so here goes:

I am using C#/.NET V1.1, etc. I have a client.exe which, when started, connects to a service on the same or different machine. For now, let's assume the client and service apps are on the same machine.

I would like to make my client application start the service if the service is not already running.

I'm using a ServiceController to get the state of the service, and I use the Start() method to start it if it is not running. This works fine, as long as the user running client.exe has Admin rights. If the user does not have Admin rights, it fails to start the service. I would like any user to be able to run client.exe and start the service if necessary.

So far, I have been going crazy trying to manually set up Code Groups in the .NET Framework Configuration Management Console snap-in. I created 2 Machine-specific MyComputer code groups, one for the folder containing my client app and one for the folder containing my service app. I granted each code group FullTrust (I verified that it had unrestricted Service Controller permission), but that did not work. I then created a custom permission set that basically amounted to FullTrust, but that did not work.

Can somebody tell me if I am on the right track? Should some combination of Code Group and Permission Set work? Should I be doing something else?

I have seen that there is a ServiceControllerPermission object. Should I be using that somehow?

There is very little documentation on Code Access Security and these other security objects, so any help, hints, or nudges in the right direction would be very appreciated.

Thanks.
 
The first link shows promise. I am really looking for a programmatic solution that wouldn't require any manual set-up on behalf of the user. But, if the "run as" works, I could change all short-cuts during the installation process.

Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top