There is a windows service that is responsible for performing the updates, you can stop this service with the following code:
ServiceController sc = new ServiceController("wuauserv");
try
{
if (sc != null && sc.Status == ServiceControllerStatus.Running)
{
sc.Stop();
}
sc.WaitForStatus(ServiceControllerStatus.Stopped);
sc.Close();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
You will need:
- Add a reference to the proyect selecting "Add Reference" into Project Name then Add
System.ServiceProcess
- Include
using System.ServiceProcess;
in your class - Run your application or Visual Studio as Administrator