Share via

Unable to download the windows update using script for Windows 10 from standard user

Anonymous
2018-05-22T03:24:27+00:00

I am running Windows 2015 LTSB and use below script to download the Windows patches as and when required.      

Script source : https://msdn.microsoft.com/en-us/library/windows/desktop/aa387102(v=vs.85).aspx

{code}

Set updateSession = CreateObject("Microsoft.Update.Session")

updateSession.ClientApplicationID = "MSDN Sample Script"

Set updateSearcher = updateSession.CreateUpdateSearcher()

WScript.Echo "Searching for updates..." & vbCRLF

Set searchResult = _

updateSearcher.Search("IsInstalled=0 and Type='Software' and IsHidden=0")

WScript.Echo "List of applicable items on the machine:"

For I = 0 To searchResult.Updates.Count-1

    Set update = searchResult.Updates.Item(I)

    WScript.Echo I + 1 & "> " & update.Title

Next

If searchResult.Updates.Count = 0 Then

    WScript.Echo "There are no applicable updates."

    WScript.Quit

End If

WScript.Echo vbCRLF & "Creating collection of updates to download:"

Set updatesToDownload = CreateObject("Microsoft.Update.UpdateColl")

For I = 0 to searchResult.Updates.Count-1

    Set update = searchResult.Updates.Item(I)

    addThisUpdate = false

    If update.InstallationBehavior.CanRequestUserInput = true Then

        WScript.Echo I + 1 & "> skipping: " & update.Title & _

        " because it requires user input"

    Else

        If update.EulaAccepted = false Then

            WScript.Echo I + 1 & "> note: " & update.Title & _

            " has a license agreement that must be accepted:"

            WScript.Echo update.EulaText

            WScript.Echo "Do you accept this license agreement? (Y/N)"

            strInput = WScript.StdIn.Readline

            WScript.Echo 

            If (strInput = "Y" or strInput = "y") Then

                update.AcceptEula()

                addThisUpdate = true

            Else

                WScript.Echo I + 1 & "> skipping: " & update.Title & _

                " because the license agreement was declined"

            End If

        Else

            addThisUpdate = true

        End If

    End If

    If addThisUpdate = true Then

        WScript.Echo I + 1 & "> adding: " & update.Title 

        updatesToDownload.Add(update)

    End If

Next

If updatesToDownload.Count = 0 Then

    WScript.Echo "All applicable updates were skipped."

    WScript.Quit

End If

WScript.Echo vbCRLF & "Downloading updates..."

Set downloader = updateSession.CreateUpdateDownloader() 

downloader.Updates = updatesToDownload

downloader.Download()

Set updatesToInstall = CreateObject("Microsoft.Update.UpdateColl")

rebootMayBeRequired = false

WScript.Echo vbCRLF & "Successfully downloaded updates:"

For I = 0 To searchResult.Updates.Count-1

    set update = searchResult.Updates.Item(I)

    If update.IsDownloaded = true Then

        WScript.Echo I + 1 & "> " & update.Title 

        updatesToInstall.Add(update) 

        If update.InstallationBehavior.RebootBehavior > 0 Then

            rebootMayBeRequired = true

        End If

    End If

Next

If updatesToInstall.Count = 0 Then

    WScript.Echo "No updates were successfully downloaded."

    WScript.Quit

End If

If rebootMayBeRequired = true Then

    WScript.Echo vbCRLF & "These updates may require a reboot."

End If

WScript.Echo  vbCRLF & "Would you like to install updates now? (Y/N)"

strInput = WScript.StdIn.Readline

WScript.Echo 

If (strInput = "Y" or strInput = "y") Then

    WScript.Echo "Installing updates..."

    Set installer = updateSession.CreateUpdateInstaller()

    installer.Updates = updatesToInstall

    Set installationResult = installer.Install()

    'Output results of install

    WScript.Echo "Installation Result: " & _

    installationResult.ResultCode 

    WScript.Echo "Reboot Required: " & _ 

    installationResult.RebootRequired & vbCRLF 

    WScript.Echo "Listing of updates installed " & _

    "and individual installation results:" 

    For I = 0 to updatesToInstall.Count - 1

        WScript.Echo I + 1 & "> " & _

        updatesToInstall.Item(i).Title & _

        ": " & installationResult.GetUpdateResult(i).ResultCode   

    Next

End If

{code}

Previously the below script use to work from standard user, but from past few days it just shows the message as below (Only from standard user on windows 10):

=====================================================

Microsoft (R) Windows Script Host Version 5.812

Copyright (C) Microsoft Corporation. All rights reserved.

Searching for updates...

List of applicable items on the machine:

1> Microsoft Silverlight (KB4023307)

2> 2018-05 Security Update for Adobe Flash Player for Windows 10 Version 1803 for x86-based Systems (KB4103729)

3> Definition Update for Windows Defender Antivirus - KB2267602 (Definition 1.267.1773.0)

Creating collection of updates to download:

1> adding: Microsoft Silverlight (KB4023307)

2> adding: 2018-05 Security Update for Adobe Flash Player for Windows 10 Version 1803 for x86-based Systems (KB4103729)

3> adding: Definition Update for Windows Defender Antivirus - KB2267602 (Definition 1.267.1773.0)

Downloading updates...

C:\Users\normal user\Desktop\WindowsUpdate\windowsUpdate.vbs(67, 1) (null): 0x80240044

=====================================================

Windows Update Log just for reference :

=====================================================

2018/05/18 14:56:16.9913163 7836  3668  ComApi          Updates found = 5

2018/05/18 14:56:16.9913177 7836  3668  ComApi          * END *   Search ClientId = MSDN Sample Script

2018/05/18 14:56:16.9940363 7836  3712  ComApi          ISusInternal:: DisconnectCall failed, hr=8024000C

2018/05/18 14:56:17.0056985 7836  3712  ComApi          * START *   Download ClientId = MSDN Sample Script

2018/05/18 14:56:17.0056994 7836  3712  ComApi          Flags: 0X10016; Download priority: 3; Network Cost Policy: 4

2018/05/18 14:56:17.0057008 7836  3712  ComApi          Updates in request: 5

2018/05/18 14:56:17.0057177 7836  3712  ComApi          ServiceID = {9482F4B4-E343-43B6-B170-9A65BC822C77} Windows Update

2018/05/18 14:56:17.0100163 7836  3712  ComApi          ISusInternal:: BeginDownloadUpdates failed, hr=80240044

2018/05/18 14:56:17.0100510 7836  3712  ComApi          Exit code = 0x80240044

2018/05/18 14:56:17.0100519 7836  3712  ComApi          * END *   Download ClientId = NULL

=====================================================

It seems downloader.Download() is behaving differently for Administrator and Standard user, specially on Windows 10 because same script is working fine on Windows 8.1 for standard user.

As per my understanding it seems like some issue on Windows side, could anyone help me to provide workaround for same ?

Windows for home | Windows 10 | Windows update

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

3 answers

Sort by: Most helpful
  1. Anonymous
    2018-05-22T09:06:21+00:00

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2018-05-22T08:56:18+00:00

    Hi nishant.rai,

    This concern is best addressed by our dedicated community in Microsoft Developers Network forums or MSDN.

    Let us know if you have other concerns.

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2018-05-22T08:11:28+00:00

    >It seems downloader.Download() is behaving differently for Administrator and Standard user, specially on Windows 10 because same script is working fine on Windows 8.1

    Can anyone help us to provide test result for the attached script on different system platform with Admin User and Standard User?

    Was this answer helpful?

    0 comments No comments