Disable the Windows service when the application starts.

Due to VLC conflict I need to disable Windows Advanced Text Services when starting my application. Is there any special API for this? Will it work for users with default privileges?

+6
c # windows vlc
source share
5 answers
ServiceController _ServiceController = new ServiceController([NameService]); if (!_ServiceController.ServiceHandle.IsInvalid) { _ServiceController.Stop(); _ServiceController.WaitForStatus(ServiceControllerStatus.Stopped, TimeSpan.FromMilliseconds(uConstante.CtTempoEsperaRespostaServico)); } 
+2
source share

A question called "Disable the Windows service ...", but the answers all talk about how to stop the service.

Most of what you find on Google is that you can update the registry to disable the service using something like this:

 RegistryKey key = Registry.LocalMachine.OpenSubKey(@"SYSTEM\CurrentControlSet\Services\[YourServiceName]", true); key.SetValue("Start", 4); 

I have not tried this method, but it seems that it will work. I also came up with another method that uses sc.exe to disable the service:

 Process sc = Process.Start("sc.exe", "config [YourServiceName] start= disabled"); 
+21
source share

You can use the ServiceController class to do this. The related documentation page has code examples.

+1
source share

You can use WMI for this.

Take a look here, for example: http://www.csharpfriends.com/Articles/getArticle.aspx?articleID=114

0
source share

just run "net stop service-name" to stop the service or "net start service-name" to start the service. type "net start" in the console (cmd.exe) to list all services.

To enable / disable services, you need administrator rights.

0
source share

All Articles