Contact Info

Crumbtrail

ActiveXperts.com » Administration » VBScript Collection » Software Update Services » Client-Side Management

Scripting Software Update Services - Client-Side Management

Display the Settings Dialog Box
Display the Software Update Service Wizard
Install an Update
List Client-Side Settings
List Proxy Properties
List Service Properties
List System Information Properties
List Search Properties
List Update History
Modify the Update Schedule
Search for Driver Updates
Search for Software Updates
Uninstall an Update


You can use any of the VBScript programs below in ActiveXperts Network Monitor. Click here for an explanation about how to include scripts in ActiveXperts Network Monitor.

Display the Settings Dialog Box


Displays the Software Updates Service settings dialog box.
Set objAutoUpdate = CreateObject("Microsoft.Update.AutoUpdate")
objAutoUpdate.ShowSettingsDialog
	

Display the Software Update Service Wizard


Locates update ac94db3b-e1a8-4e92-9fd0-e86f355e6a44 and then displays the Software Update Service wizard.
Set objCollection = CreateObject("Microsoft.Update.UpdateColl")

Set objSearcher = CreateObject("Microsoft.Update.Searcher")
Set objResults = objSearcher.Search _
    ("UpdateID='ac94db3b-e1a8-4e92-9fd0-e86f355e6a44'")
Set colUpdates = objResults.Updates

objCollection.Add(colUpdates.Item(0))
Set objInstaller = CreateObject("Microsoft.Update.Installer")
objInstaller.Updates = objCollection
Set objResults = objInstaller.RunWizard
	

Install an Update


Installs update ac94db3b-e1a8-4e92-9fd0-e86f355e6a44.
Set objCollection = CreateObject("Microsoft.Update.UpdateColl")

Set objSearcher = CreateObject("Microsoft.Update.Searcher")
Set objResults = objSearcher.Search _
    ("UpdateID='ac94db3b-e1a8-4e92-9fd0-e86f355e6a44'")
Set colUpdates = objResults.Updates
objCollection.Add(colUpdates.Item(0))

Set objInstaller = CreateObject("Microsoft.Update.Installer")
objInstaller.Updates = objCollection
Set objInstallResults = objInstaller.Install
Wscript.Echo objInstallResults.Exception
Wscript.Echo objInstallResults.RebootRequired
Wscript.Echo objInstallResults.ResultCode
	

List Client-Side Settings


Displays client-side Software Update Service settings.
Set objAutoUpdate = CreateObject("Microsoft.Update.AutoUpdate")
Wscript.Echo "Service enabled: " & objAutoUpdate.ServiceEnabled

Set objSettings = objAutoUpdate.Settings

Wscript.Echo "Notification level: " & objSettings.NotificationLevel
Wscript.Echo "Read-only: " & objSettings.ReadOnly
Wscript.Echo "Required: " & objSettings.Required
Wscript.Echo "Scheduled Installation Day: " & _
    objSettings.ScheduledInstallationDay
Wscript.Echo "Scheduled Installation Time: " & _
    objSettings.ScheduledInstallationTime
	

List Proxy Properties


Displays proxy settings for Software Update Services.
Set objProxy = CreateObject("Microsoft.Update.WebProxy")

Wscript.Echo "Address: " & objProxy.Address
Wscript.Echo "Bypass proxy on local addresses: " & objProxy.BypassProxyOnLocal
Wscript.Echo "Read-only: " & objProxy.Readonly
Wscript.Echo "User name: " & objProxy.UserName
	

List Service Properties


Displays service properties for Software Update Services.
Set objServiceManager = CreateObject("Microsoft.Update.ServiceManager")
Set colServices = objServiceManager.Services

For i = 0 to colServices.Count - 1
    Wscript.Echo "Name: " & colServices.Item(i).Name
    Wscript.Echo "Is managed: " & colServices.Item(i).IsManaged
    Wscript.Echo "Is registered with Automatic Updates: " & _
        colServices.Item(i).IsRegisteredWithAU
    Wscript.Echo "Issue date: " & colServices.Item(i).IssueDate
    Wscript.Echo "Offers Windows updates: " & _
        colServices.Item(i).OffersWindowsUpdates
    Wscript.Echo  "Redirection URL: " &colServices.Item(i).RedirectURL
    Wscript.Echo "Service ID: " & colServices.Item(i).ServiceID
    Wscript.Echo "UI Plugin Class ID: " & colServices.Item(i).UIPluginClsid
Next
	

List System Information Properties


Displays basic system information properties for Software Update Services.
Set objSysInfo = CreateObject("Microsoft.Update.SystemInfo")

Wscript.Echo "OEM hardware support link: " & objSysInfo.OEMHardwareSupportLink
Wscript.Echo "Reboot required: " & objSysInfo.RebootRequired
	

List Search Properties


Displays search settings for Software Update Services.
Set objSearcher = CreateObject("Microsoft.Update.Searcher")

Wscript.Echo "Can automatically upgrade service: " & _
    objSearcher.CanAutomaticallyUpgradeService
Wscript.Echo "Client application ID: " & objSearcher.ClientApplicationID
Wscript.Echo "Online: " & objSearcher.Online
Wscript.Echo "Server selection: " & objSearcher.ServerSelection
Wscript.Echo "Service ID: " & objSearcher.ServiceID
	

List Update History


Displays all the updates that have been installed on a computer.
Set objSession = CreateObject("Microsoft.Update.Session")
Set objSearcher = objSession.CreateUpdateSearcher
intHistoryCount = objSearcher.GetTotalHistoryCount

Set colHistory = objSearcher.QueryHistory(1, intHistoryCount)

For Each objEntry in colHistory
    Wscript.Echo "Operation: " & objEntry.Operation
    Wscript.Echo "Result code: " & objEntry.ResultCode
    Wscript.Echo "Exception: " & objEntry.Exception
    Wscript.Echo "Date: " & objEntry.Date
    Wscript.Echo "Title: " & objEntry.Title
    Wscript.Echo "Description: " & objEntry.Description
    Wscript.Echo "Unmapped exception: " & objEntry.UnmappedException
    Wscript.Echo "Client application ID: " & objEntry.ClientApplicationID
    Wscript.Echo "Server selection: " & objEntry.ServerSelection
    Wscript.Echo "Service ID: " & objEntry.ServiceID
    i = 1
    For Each strStep in objEntry.UninstallationSteps
        Wscript.Echo i & " -- " & strStep
        i = i + 1
    Next
    Wscript.Echo "Uninstallation notes: " & objEntry.UninstallationNotes
    Wscript.Echo "Support URL: " & objEntry.SupportURL
    Wscript.Echo
Next
	

Modify the Update Schedule


Demonstration script that modifies the software update schedule.
Set objAutoUpdate = CreateObject("Microsoft.Update.AutoUpdate")
Set objSettings = objAutoUpdate.Settings

objSettings.ScheduledInstallationDay = 3
objSettings.ScheduledInstallationTime = 4

objSettings.Save
	

Search for Driver Updates


Demonstration script that searches for new driver update.
@Set objSearcher = CreateObject("Microsoft.Update.Searcher")
Set objResults = objSearcher.Search("Type='Driver'")
Set colUpdates = objResults.Updates

Wscript.Echo colUpdates.Count

For i = 0 to colUpdates.Count - 1
    Wscript.Echo "Title: " & colUpdates.Item(i).Title
    Wscript.Echo "Autoselect on Web sites: " & _
        colUpdates.Item(i).AutoSelectOnWebSites

    For Each strUpdate in colUpdates.Item(i).BundledUpdates
        Wscript.Echo "Bundled update: " & strUpdate
    Next

    Wscript.Echo "Can require source: " & colUpdates.Item(i).CanRequireSource
    Set objCategories = colUpdates.Item(i).Categories

    For z = 0 to objCategories.Count - 1
        Wscript.Echo "Category name: " & objCategories.Item(z).Name
        Wscript.Echo "Category ID: " & objCategories.Item(z).CategoryID
        For Each strChild in objCategories.Item(z).Children
            Wscript.Echo "Child category: " & strChild
        Next
        Wscript.Echo "Category description: " & _
            objCategories.Item(z).Description
        Wscript.Echo "Category order: " & objCategories.Item(z).Order
        Wscript.Echo "Category type: " & objCategories.Item(z).Type
    Next

    Wscript.Echo "Deadline: " & colUpdates.Item(i).Deadline
    Wscript.Echo "Delta compressed content available: " & _
        colUpdates.Item(i).DeltaCompressedContentAvailable
    Wscript.Echo "Delta compressed content preferred: " & _
        colUpdates.Item(i).DeltaCompressedContentPreferred
    Wscript.Echo "Description: " & colUpdates.Item(i).Description
    Wscript.Echo "EULA accepted: " & colUpdates.Item(i).EULAAccepted
    Wscript.Echo "EULA text: " & colUpdates.Item(i).EULAText
    Wscript.Echo "Handler ID: " & colUpdates.Item(i).HandlerID

    Set objIdentity = colUpdates.Item(i).Identity
    Wscript.Echo "Revision number: " & objIdentity.RevisionNumber
    Wscript.Echo "Update ID: " & objIdentity.UpdateID

    Set objInstallationBehavior = colUpdates.Item(i).InstallationBehavior
    Wscript.Echo "Can request user input: " & _
        objInstallationBehavior.CanRequestUserInput
    Wscript.Echo "Impact: " & objInstallationBehavior.Impact
    Wscript.Echo "Reboot behavior: " & objInstallationBehavior.RebootBehavior
    Wscript.Echo "Requires network connectivity: " & _
        objInstallationBehavior.RequiresNetworkConnectivity
    Wscript.Echo "Is beta: " & colUpdates.Item(i).IsBeta
    Wscript.Echo "Is hidden: " & colUpdates.Item(i).IsHidden
    Wscript.Echo "Is installed: " & colUpdates.Item(i).IsInstalled
    Wscript.Echo "Is mandatory: " & colUpdates.Item(i).IsMandatory
    Wscript.Echo "Is uninstallable: " & colUpdates.Item(i).IsUninstallable

    For Each strLanguage in colUpdates.Item(i).Languages
        Wscript.Echo "Supported language: " & strLanguage
    Next

    Wscript.Echo "Last deployment change time: " & _
        colUpdates.Item(i).LastDeploymentChangeTime
    Wscript.Echo "Maximum download size: " & colUpdates.Item(i).MaxDownloadSize
    Wscript.Echo "Minimum download size: " & colUpdates.Item(i).MinDownloadSize
    Wscript.Echo "Microsoft Security Response Center severity: " & _
        colUpdates.Item(i).MsrcSeverity
    Wscript.Echo "Recommended CPU speed: " & _
        colUpdates.Item(i).RecommendedCPUSpeed
    Wscript.Echo "Recommended hard disk space: " & _
        colUpdates.Item(i).RecommendedHardDiskSpace
    Wscript.Echo "Recommended memory: " & colUpdates.Item(i).RecommendedMemory
    Wscript.Echo "Release notes: " & colUpdates.Item(i).ReleaseNotes
    Wscript.Echo "Support URL: " & colUpdates.Item(i).SupportURL
    Wscript.Echo "Type: " & colUpdates.Item(i).Type
    Wscript.Echo "Uninstallation notes: " & _
        colUpdates.Item(i).UninstallationNotes

    x = 1
    For Each strStep in colUpdates.Item(i).UninstallationSteps
        Wscript.Echo x & " -- " & strStep
        x = x + 1
    Next

    For Each strArticle in colUpdates.Item(i).KBArticleIDs
        Wscript.Echo "KB article: " & strArticle
    Next

    Wscript.Echo "Deployment action: " & colUpdates.Item(i).DeploymentAction
    Wscript.Echo

Next
	

Search for Software Updates


Demonstration script that searches for new software updates.
Set objSearcher = CreateObject("Microsoft.Update.Searcher")
Set objResults = objSearcher.Search("Type='Software'")
Set colUpdates = objResults.Updates

For i = 0 to colUpdates.Count - 1
    Wscript.Echo "Title: " & colUpdates.Item(i).Title
    Wscript.Echo "Autoselect on Web sites: " & _
        colUpdates.Item(i).AutoSelectOnWebSites

    For Each strUpdate in colUpdates.Item(i).BundledUpdates
        Wscript.Echo "Bundled update: " & strUpdate
    Next
    Wscript.Echo "Can require source: " & colUpdates.Item(i).CanRequireSource
    Set objCategories = colUpdates.Item(i).Categories

    For z = 0 to objCategories.Count - 1
        Wscript.Echo "Category name: " & objCategories.Item(z).Name
        Wscript.Echo "Category ID: " & objCategories.Item(z).CategoryID
        For Each strChild in objCategories.Item(z).Children
            Wscript.Echo "Child category: " & strChild
        Next
        Wscript.Echo "Category description: " & _
            objCategories.Item(z).Description
        Wscript.Echo "Category order: " & objCategories.Item(z).Order
        Wscript.Echo "Category type: " & objCategories.Item(z).Type
    Next

    Wscript.Echo "Deadline: " & colUpdates.Item(i).Deadline
    Wscript.Echo "Delta compressed content available: " & _
        colUpdates.Item(i).DeltaCompressedContentAvailable
    Wscript.Echo "Delta compressed content preferred: " & _
        colUpdates.Item(i).DeltaCompressedContentPreferred
    Wscript.Echo "Description: " & colUpdates.Item(i).Description
    Wscript.Echo "EULA accepted: " & colUpdates.Item(i).EULAAccepted
    Wscript.Echo "EULA text: " & colUpdates.Item(i).EULAText
    Wscript.Echo "Handler ID: " & colUpdates.Item(i).HandlerID

    Set objIdentity = colUpdates.Item(i).Identity
    Wscript.Echo "Revision number: " & objIdentity.RevisionNumber
    Wscript.Echo "Update ID: " & objIdentity.UpdateID

    Set objInstallationBehavior = colUpdates.Item(i).InstallationBehavior
    Wscript.Echo "Can request user input: " & _
        objInstallationBehavior.CanRequestUserInput
    Wscript.Echo "Impact: " & objInstallationBehavior.Impact
    Wscript.Echo "Reboot behavior: " & objInstallationBehavior.RebootBehavior
    Wscript.Echo "Requires network connectivity: " & _
        objInstallationBehavior.RequiresNetworkConnectivity
    Wscript.Echo "Is beta: " & colUpdates.Item(i).IsBeta
    Wscript.Echo "Is hidden: " & colUpdates.Item(i).IsHidden
    Wscript.Echo "Is installed: " & colUpdates.Item(i).IsInstalled
    Wscript.Echo "Is mandatory: " & colUpdates.Item(i).IsMandatory
    Wscript.Echo "Is uninstallable: " & colUpdates.Item(i).IsUninstallable

    For Each strLanguage in colUpdates.Item(i).Languages
        Wscript.Echo "Supported language: " & strLanguage
    Next

    Wscript.Echo "Last deployment change time: " & _
        colUpdates.Item(i).LastDeploymentChangeTime
    Wscript.Echo "Maximum download size: " & colUpdates.Item(i).MaxDownloadSize
    Wscript.Echo "Minimum download size: " & colUpdates.Item(i).MinDownloadSize
    Wscript.Echo "Microsoft Security Response Center severity: " & _
        colUpdates.Item(i).MsrcSeverity
    Wscript.Echo "Recommended CPU speed: " & _
        colUpdates.Item(i).RecommendedCPUSpeed
    Wscript.Echo "Recommended hard disk space: " & _
        colUpdates.Item(i).RecommendedHardDiskSpace
    Wscript.Echo "Recommended memory: " & colUpdates.Item(i).RecommendedMemory
    Wscript.Echo "Release notes: " & colUpdates.Item(i).ReleaseNotes
    Wscript.Echo "Support URL: " & colUpdates.Item(i).SupportURL
    Wscript.Echo "Type: " & colUpdates.Item(i).Type
    Wscript.Echo "Uninstallation notes: " & _
        colUpdates.Item(i).UninstallationNotes

    x = 1
    For Each strStep in colUpdates.Item(i).UninstallationSteps
        Wscript.Echo x & " -- " & strStep
        x = x + 1
    Next

    For Each strArticle in colUpdates.Item(i).KBArticleIDs
        Wscript.Echo "KB article: " & strArticle
    Next

    Wscript.Echo "Deployment action: " & colUpdates.Item(i).DeploymentAction
    Wscript.Echo
Next
	

Uninstall an Update


Uninstalls update ac94db3b-e1a8-4e92-9fd0-e86f355e6a44.
Set objCollection = CreateObject("Microsoft.Update.UpdateColl")

Set objSearcher = CreateObject("Microsoft.Update.Searcher")
Set objResults = objSearcher.Search _
    ("UpdateID='ac94db3b-e1a8-4e92-9fd0-e86f355e6a44'")

Set colUpdates = objResults.Updates
Wscript.echo colUpdates.count

objCollection.Add(colUpdates.Item(0))
Wscript.echo objCollection.count

Set objInstaller = CreateObject("Microsoft.Update.Installer")
objInstaller.Updates = objCollection

Set objInstallResults = objInstaller.Uninstall
Wscript.Echo objInstallResults.Exception
Wscript.Echo objInstallResults.RebootRequired
Wscript.Echo objInstallResults.ResultCode