I am working on a project and need to automate disabling Windows Automatic Update using my C# code. I am not quite sure where to start. I have read about possibly using the Windows Update Agent API but am not sure. Any advice would be greatly appreciated. Thanks in advance.
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:
System.ServiceProcess
using System.ServiceProcess;
in your class