Hi @Pacoss ,
The issue is security related as the account does not have sufficient privileges to start/stop the service.
You need to impersonate the application/code section with user credentials with appropriate permissions and access to the window service.
You can simulate via web.config
or in code
.
Details can be found in the documentation:
https://learn.microsoft.com/zh-CN/troubleshoot/developer/webapps/aspnet/ftp-authentication-authorization/implement-impersonation
https://weblogs.asp.net/kaushal/start-stop-window-service-from-asp-net-page
Web.config
<identity impersonate="true" userName="accountname" password="password" />
In code
System.Security.Principal.WindowsImpersonationContext impersonationContext;
impersonationContext = ((System.Security.Principal.WindowsIdentity)User.Identity).Impersonate();
//Insert your code that runs under the security context of the authenticating user here.
impersonationContext.Undo();
Best regards,
Lan Huang
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.