Check with .NET if Windows Update is On

Is there a way to check .NET if Windows update is enabled?

I want users to each time they enter my application indicate that their computer may be at risk and give them a link to the Windows update site (or the Windows update application from the control panel).

Preferably, it should work on XP, Vista, and Windows 7. Maybe there is a registry key or even a better API?

+5
source share
6 answers

First add the link to WUApiLib "C: \ windows \ system32 \ Wuapi.dll"

Then you can use this piece of code.

WUApiLib.AutomaticUpdatesClass auc = new WUApiLib.AutomaticUpdatesClass();
bool active = auc.ServiceEnabled;

MSDN: " ServiceEnabled , , ".

auc.Settings.NotificationLevel . http://msdn.microsoft.com/en-us/library/aa385806(VS.85).aspx

+8

, , , WindowsUpdate , , WindowsUpdate, XP.

. . , , WU , .

+5

.

HKEY_LOCAL_MACHINE
  SOFTWARE
   Microsoft
     Active Setup
       Installed Components
         {89820200-ECBD-11cf-8B85-00AA005B4340}

IsInstalled 1, Windows.

:

http://windowsitpro.com/article/articleid/15266/how-can-i-detect-if-windows-update-is-installed-on-a-machine.html

, , , XP SP3, .

+2

, Windows PROCESS.

- :

Function CheckIfServiceIsRunning(ByVal serviceName As String) As Boolean
   Dim mySC As ServiceProcess.ServiceController
   mySC = New ServiceProcess.ServiceController(serviceName)
   If mySC.Status = ServiceProcess.ServiceControllerStatus.Stopped Then
      ' Service isn't running
      Return False
   ElseIf mySC.Status = ServiceProcess.ServiceControllerStatus.Running Then
      ' Service already running
      Return True
   End If
End Function

, "Wuauserv"

+1

Michael Pendl’s answer didn’t work for me, but he gave me the information I needed for her to work:

WUApiLib.AutomaticUpdatesClass auc = new WUApiLib.AutomaticUpdatesClass();<br>
string notificationLevel = auc.Settings.NotificationLevel.ToString();<br><br>

The line notificationLevelwill vary depending on which option is selected in the Automatic Updates dialog box.

0
source

All Articles