简体   繁体   中英

Restart windows service on server (Windows 2008 R2) having UAC turned ON (from ASP.NET application)

I am trying to restart a windows service (part of the application) from my ASP.NET (.Net 4) application but it fails with the error:

Cannot open <ServiceName> service on computer '.'.
Inner Exception: Access is denied
StackTrace:  at System.ServiceProcess.ServiceController.GetServiceHandle(Int32 desiredAccess)
   at System.ServiceProcess.ServiceController.Start(String[] args)
   at NetClient.AvailabilityConfiguration.StartAvailabilityService(ServiceController serviceName, TimeSpan timeout)

The code is working fine on my development machine (Windoes 7) and test server (Windows 2008 R2) but fails on the production server. The only (and BIG) difference is that UAC is turned ON the production serevr where as it is OFF on the dev and test servers.

I have tried adding an app.manifest file to the web application to get elevated privileges but it does not seem to work. I've configured the app.manifest "requestedExecutionLevel" attribute to "requireAdministrator" but does not seem to have an effect.

Any help will be greatly appreciated.

Thanks Aju

I think that is clear that the account that runs the pool of your web have not rights to manage the services (especial the Start, Stop, Pause commands).

See under what account your pool is running, and give him the permission to manage the services of your server. You can do that using the group policy, or open the security template.

Read the official detailed steps for How to grant users rights to manage services in Windows Server

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM