Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable Windows service at application launch

Tags:

c#

.net

windows

vlc

Because of VLC conflict I have to turn off Windows Advanced Text Services at my application launch. Is there any special API for that? Will it work for user with default rights?

like image 401
SiberianGuy Avatar asked Jun 16 '10 10:06

SiberianGuy


People also ask

How to disable Windows startup services in Windows 10?

The steps to disable the Windows startup services are as follows: Step 1: Press ( + R) on keyboard. The Run dialog box will appear. Step 2: Clear the content of the text box and then type msconfig in it. Step 3: Now hit Enter button. A dialog box will appear.

How to stop apps from launching at startup in Windows 10?

How to Stop Windows 10 Apps From Launching at Startup 1 Disable Startup Apps in Windows Settings. Open Settings > Apps > Startup to view a list of all apps that can start up automatically and determine which should be disabled. 2 Disable Startup Apps in Task Manager. ... 3 Research an App. ... 4 Manager Apps. ...

How do I stop a running service on Windows 10?

Using the Services consoles is perhaps the simplest method to stop, start, disable, or enable one or multiple services on Windows 10. To stop a running service using Services, use these steps: Open Start. Search for Services and click the top result to open the console. Double-click the service that you intend to stop. Click the Stop button.

How to start/stop/disable services using sc command in Windows?

To Start, Stop, and Disable Services using Sc Command 1 Open an elevated command prompt, and do step 2 (stop), step 3 (disable), step 4 (enable), or step 5 (start) below for what you would like to do. 2. To Stop a Service using "Sc Stop" Command in Command Prompt


2 Answers

The question is titled "Disable Windows service..." but the answers all tell how to stop a service.

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

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

I haven't tried that method but it appears as though it will work. I also came up with a different method that uses sc.exe to disable the service:

Process sc = Process.Start("sc.exe", "config [YourServiceName] start= disabled");
like image 121
xr280xr Avatar answered Sep 19 '22 18:09

xr280xr


ServiceController _ServiceController = new ServiceController([NameService]);
if (!_ServiceController.ServiceHandle.IsInvalid) 
{
     _ServiceController.Stop();
     _ServiceController.WaitForStatus(ServiceControllerStatus.Stopped, TimeSpan.FromMilliseconds(uConstante.CtTempoEsperaRespostaServico));
}
like image 45
Paulo Henrique Avatar answered Sep 19 '22 18:09

Paulo Henrique