VBScript to check if the new AU Client (WUA) is needed and installing it accordingly

The VBScript code below from Scripting Guru Torgeir Bakken (MVP) checks if the new AU client is needed on the computer, and runs WindowsUpdateAgent20-x86.exe if required in silent mode. Thanks Torgeir.


  1. Adjust path in the sExePath variable.

  2. If the users are local administrators, you can run the script as part of a logon script.

  3. Alternatively, if the computers are in an Active Directory domain, you can do it in a computer startup script (with a GPO) that runs as part of the boot up process (before the user logs in). It runs under the system context and has admin rights.

The script uses the IWindowsUpdateAgentInfo::GetInfo method instead of checking the version of the file wuaueng.dll. Also, if the interface does not exist because the AU client is to old, the script will install the client. The script below uses both methods to check for an already up to date version.

Option Explicit

Dim strExePath, bolUpdateNeeded, objAgentInfo
Dim intMajorVersion, objShell

‘ prefix with an UNC path if necessary
strExePath = “WindowsUpdateAgent20-x86.exe”

bolUpdateNeeded = True   ‘ init value, do not touch

On Error Resume Next
Set objAgentInfo = CreateObject(“Microsoft.Update.AgentInfo”)

If Err.Number = 0 Then
   ‘ object exists, now check if ApiMajorVersion is 3 or higher
   intMajorVersion = 0   ‘ init value
   intMajorVersion = objAgentInfo.GetInfo(“ApiMajorVersion”)
   If intMajorVersion >= 3 Then
     bolUpdateNeeded = False
   End If
End If
On Error Goto 0

If bolUpdateNeeded Then
   Set objShell = CreateObject(“WScript.Shell”)
   ‘ install the AU client
   objShell.Run strExePath & ” /quiet /norestart”, 1, True
End If


Determining the Current Version of WUA

Re-installing Windows Update Agent (WUA)

Automatic Update Client Versions History

For x86-based computers (WindowsUpdateAgent20-x86.exe)

For x64-based computers (WindowsUpdateAgent20-x64.exe):

Leave a Reply

Your email address will not be published. Required fields are marked *