Last active
November 15, 2019 14:25
-
-
Save 0o001/b98c2868b63ce442f82b88f46f7af23c to your computer and use it in GitHub Desktop.
how to Start/Stop Windows Service
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Bilgisayar servislerine erişme | |
public static void RestartService(string serviceName) | |
{ | |
ServiceController service = new ServiceController(serviceName); | |
try | |
{ | |
//Durdur | |
service.Stop(); | |
service.WaitForStatus(ServiceControllerStatus.Stopped); | |
//Başlat | |
service.Start(); | |
service.WaitForStatus(ServiceControllerStatus.Running); | |
} | |
catch | |
{ | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment