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.
NOTES:
- Adjust path in the sExePath variable.
- If the users are local administrators, you can run the script as part of a logon script.
- 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.
‘——————–8<———————-
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
‘——————–8<———————-
MORE INFORMATION
Determining the Current Version of WUA
http://msdn.microsoft.com/library/en-us/wua_sdk/wua/determining_the_current_version_of_wua.asp?frame=true
Re-installing Windows Update Agent (WUA)
http://msmvps.com/blogs/athif/archive/2006/04/05/Re_Installing_WUA.aspx
Automatic Update Client Versions History
http://msmvps.com/blogs/athif/archive/2005/06/15/Automatic_Update_Client_Versions_History.aspx
For x86-based computers (WindowsUpdateAgent20-x86.exe)
http://go.microsoft.com/fwlink/?LinkId=43264
For x64-based computers (WindowsUpdateAgent20-x64.exe):
http://go.microsoft.com/fwlink/?LinkId=43265