Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to turn windows service on if its off. control it from webapplication

i want to turn windows service on when it is off. is it possible to make via code from web application with c#? i am using asp.net mvc and c#.

like image 747
r.r Avatar asked Mar 08 '11 14:03

r.r


People also ask

Can a Windows Service launch an application?

A Windows Service may launch a UI application but this application will never be displayed on the currently logged-in user's desktop. This tip shows how to launch a UI application from a Windows Service by using the Windows API.

What is a Windows Service application?

Microsoft Windows services, formerly known as NT services, enable you to create long-running executable applications that run in their own Windows sessions. These services can be automatically started when the computer boots, can be paused and restarted, and do not show any user interface.


2 Answers

You're looking for the ServiceController class.

like image 138
SLaks Avatar answered Sep 26 '22 20:09

SLaks


Its possible to do it but its unlikely that you want to run your website under an account which has enough rights to be able to Start/Stop services. You can use the ServiceController class to start a service see here

like image 40
SecretDeveloper Avatar answered Sep 24 '22 20:09

SecretDeveloper