Force Windows Update to check for updates with filters to avoid certain types of updates?In VBScript, I need...

Variable completely messes up echoed string

In Aliens, how many people were on LV-426 before the Marines arrived​?

What exactly term 'companion plants' means?

Relation between independence and correlation of uniform random variables

Optimising a list searching algorithm

What is the significance behind "40 days" that often appears in the Bible?

Is honey really a supersaturated solution? Does heating to un-crystalize redissolve it or melt it?

What does "^L" mean in C?

Do I need to consider instance restrictions when showing a language is in P?

PTIJ What is the inyan of the Konami code in Uncle Moishy's song?

Do I need to be arrogant to get ahead?

Is there a term for accumulated dirt on the outside of your hands and feet?

Is it insecure to send a password in a `curl` command?

Writing in a Christian voice

Hausdorff dimension of the boundary of fibres of Lipschitz maps

Bash - pair each line of file

Fewest number of steps to reach 200 using special calculator

Can a medieval gyroplane be built?

World War I as a war of liberals against authoritarians?

How does 取材で訪れた integrate into this sentence?

How is the partial sum of a geometric sequence calculated?

Brake pads destroying wheels

Comment Box for Substitution Method of Integrals

How do hiring committees for research positions view getting "scooped"?



Force Windows Update to check for updates with filters to avoid certain types of updates?


In VBScript, I need a code to subtract 1 from searchResult.Updates.Count, so that Count = 0 and WScript.Quit will be run consequentlyQuickly install the latest .NET framework with all updatesCheck whether Windows Updates are being installedHibernation during WIndows 7 update results in failure to wakeDisabling windows updates for windows 10Windows 10: “We couldn't complete the updates, undoing changes”Windows 7 takes 15 min before even downloading WIndows UpdatesWindows Update Error 80244019 after long time searching for updatesWindows 10 Anniversary Update fails with error 0xc000000fWindows couldnot search for new updatesWindows 10 “Update & Security” dialog does not appear - Updates not working













0















I Need to create a program that will check for and install important updates



Would it be possible to have it only create a popup when updates are available?



Currently I am using this code to check for updates:



' Written in 2007 by Harry Johnston, University of Waikato, New Zealand.
' This code has been placed in the public domain. It may be freely
' used, modified, and distributed. However it is provided with no
' warranty, either express or implied.
'
' Exit Codes:
' 0 = scripting failure
' 1 = error obtaining or installing updates
' 2 = installation successful, no further updates to install
' 3 = reboot needed; rerun script after reboot
'
' Note that exit code 0 has to indicate failure because that is what
' is returned if a scripting error is raised.
'

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

Set updateSearcher = updateSession.CreateUpdateSearcher()
Set updateDownloader = updateSession.CreateUpdateDownloader()
Set updateInstaller = updateSession.CreateUpdateInstaller()

Do

WScript.Echo
WScript.Echo "Searching for approved updates ..."
WScript.Echo

Set updateSearch = updateSearcher.Search("IsInstalled=0")

If updateSearch.ResultCode <> 2 Then

WScript.Echo "Search failed with result code", updateSearch.ResultCode
WScript.Quit 1

End If

If updateSearch.Updates.Count = 0 Then

WScript.Echo "There are no updates to install."
WScript.Quit 2

End If

Set updateList = updateSearch.Updates

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

Set update = updateList.Item(I)

WScript.Echo "Update found:", update.Title

Next

WScript.Echo

updateDownloader.Updates = updateList
updateDownloader.Priority = 3

Set downloadResult = updateDownloader.Download()

If downloadResult.ResultCode <> 2 Then

WScript.Echo "Download failed with result code", downloadResult.ResultCode
WScript.Echo

WScript.Quit 1

End If

WScript.Echo "Download complete. Installing updates ..."
WScript.Echo

updateInstaller.Updates = updateList

Set installationResult = updateInstaller.Install()

If installationResult.ResultCode <> 2 Then

WScript.Echo "Installation failed with result code", installationResult.ResultCode

For I = 0 to updateList.Count - 1

Set updateInstallationResult = installationResult.GetUpdateResult(I)
WScript.Echo "Result for " & updateList.Item(I).Title & " is " & installationResult.GetUpdateResult(I).ResultCode

Next

WScript.Quit 1

End If

If installationResult.RebootRequired Then

WScript.Echo "The system must be rebooted to complete installation."

WScript.Quit 3

End If

WScript.Echo "Installation complete."

Loop









share|improve this question
















bumped to the homepage by Community 13 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.




















    0















    I Need to create a program that will check for and install important updates



    Would it be possible to have it only create a popup when updates are available?



    Currently I am using this code to check for updates:



    ' Written in 2007 by Harry Johnston, University of Waikato, New Zealand.
    ' This code has been placed in the public domain. It may be freely
    ' used, modified, and distributed. However it is provided with no
    ' warranty, either express or implied.
    '
    ' Exit Codes:
    ' 0 = scripting failure
    ' 1 = error obtaining or installing updates
    ' 2 = installation successful, no further updates to install
    ' 3 = reboot needed; rerun script after reboot
    '
    ' Note that exit code 0 has to indicate failure because that is what
    ' is returned if a scripting error is raised.
    '

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

    Set updateSearcher = updateSession.CreateUpdateSearcher()
    Set updateDownloader = updateSession.CreateUpdateDownloader()
    Set updateInstaller = updateSession.CreateUpdateInstaller()

    Do

    WScript.Echo
    WScript.Echo "Searching for approved updates ..."
    WScript.Echo

    Set updateSearch = updateSearcher.Search("IsInstalled=0")

    If updateSearch.ResultCode <> 2 Then

    WScript.Echo "Search failed with result code", updateSearch.ResultCode
    WScript.Quit 1

    End If

    If updateSearch.Updates.Count = 0 Then

    WScript.Echo "There are no updates to install."
    WScript.Quit 2

    End If

    Set updateList = updateSearch.Updates

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

    Set update = updateList.Item(I)

    WScript.Echo "Update found:", update.Title

    Next

    WScript.Echo

    updateDownloader.Updates = updateList
    updateDownloader.Priority = 3

    Set downloadResult = updateDownloader.Download()

    If downloadResult.ResultCode <> 2 Then

    WScript.Echo "Download failed with result code", downloadResult.ResultCode
    WScript.Echo

    WScript.Quit 1

    End If

    WScript.Echo "Download complete. Installing updates ..."
    WScript.Echo

    updateInstaller.Updates = updateList

    Set installationResult = updateInstaller.Install()

    If installationResult.ResultCode <> 2 Then

    WScript.Echo "Installation failed with result code", installationResult.ResultCode

    For I = 0 to updateList.Count - 1

    Set updateInstallationResult = installationResult.GetUpdateResult(I)
    WScript.Echo "Result for " & updateList.Item(I).Title & " is " & installationResult.GetUpdateResult(I).ResultCode

    Next

    WScript.Quit 1

    End If

    If installationResult.RebootRequired Then

    WScript.Echo "The system must be rebooted to complete installation."

    WScript.Quit 3

    End If

    WScript.Echo "Installation complete."

    Loop









    share|improve this question
















    bumped to the homepage by Community 13 mins ago


    This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.


















      0












      0








      0








      I Need to create a program that will check for and install important updates



      Would it be possible to have it only create a popup when updates are available?



      Currently I am using this code to check for updates:



      ' Written in 2007 by Harry Johnston, University of Waikato, New Zealand.
      ' This code has been placed in the public domain. It may be freely
      ' used, modified, and distributed. However it is provided with no
      ' warranty, either express or implied.
      '
      ' Exit Codes:
      ' 0 = scripting failure
      ' 1 = error obtaining or installing updates
      ' 2 = installation successful, no further updates to install
      ' 3 = reboot needed; rerun script after reboot
      '
      ' Note that exit code 0 has to indicate failure because that is what
      ' is returned if a scripting error is raised.
      '

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

      Set updateSearcher = updateSession.CreateUpdateSearcher()
      Set updateDownloader = updateSession.CreateUpdateDownloader()
      Set updateInstaller = updateSession.CreateUpdateInstaller()

      Do

      WScript.Echo
      WScript.Echo "Searching for approved updates ..."
      WScript.Echo

      Set updateSearch = updateSearcher.Search("IsInstalled=0")

      If updateSearch.ResultCode <> 2 Then

      WScript.Echo "Search failed with result code", updateSearch.ResultCode
      WScript.Quit 1

      End If

      If updateSearch.Updates.Count = 0 Then

      WScript.Echo "There are no updates to install."
      WScript.Quit 2

      End If

      Set updateList = updateSearch.Updates

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

      Set update = updateList.Item(I)

      WScript.Echo "Update found:", update.Title

      Next

      WScript.Echo

      updateDownloader.Updates = updateList
      updateDownloader.Priority = 3

      Set downloadResult = updateDownloader.Download()

      If downloadResult.ResultCode <> 2 Then

      WScript.Echo "Download failed with result code", downloadResult.ResultCode
      WScript.Echo

      WScript.Quit 1

      End If

      WScript.Echo "Download complete. Installing updates ..."
      WScript.Echo

      updateInstaller.Updates = updateList

      Set installationResult = updateInstaller.Install()

      If installationResult.ResultCode <> 2 Then

      WScript.Echo "Installation failed with result code", installationResult.ResultCode

      For I = 0 to updateList.Count - 1

      Set updateInstallationResult = installationResult.GetUpdateResult(I)
      WScript.Echo "Result for " & updateList.Item(I).Title & " is " & installationResult.GetUpdateResult(I).ResultCode

      Next

      WScript.Quit 1

      End If

      If installationResult.RebootRequired Then

      WScript.Echo "The system must be rebooted to complete installation."

      WScript.Quit 3

      End If

      WScript.Echo "Installation complete."

      Loop









      share|improve this question
















      I Need to create a program that will check for and install important updates



      Would it be possible to have it only create a popup when updates are available?



      Currently I am using this code to check for updates:



      ' Written in 2007 by Harry Johnston, University of Waikato, New Zealand.
      ' This code has been placed in the public domain. It may be freely
      ' used, modified, and distributed. However it is provided with no
      ' warranty, either express or implied.
      '
      ' Exit Codes:
      ' 0 = scripting failure
      ' 1 = error obtaining or installing updates
      ' 2 = installation successful, no further updates to install
      ' 3 = reboot needed; rerun script after reboot
      '
      ' Note that exit code 0 has to indicate failure because that is what
      ' is returned if a scripting error is raised.
      '

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

      Set updateSearcher = updateSession.CreateUpdateSearcher()
      Set updateDownloader = updateSession.CreateUpdateDownloader()
      Set updateInstaller = updateSession.CreateUpdateInstaller()

      Do

      WScript.Echo
      WScript.Echo "Searching for approved updates ..."
      WScript.Echo

      Set updateSearch = updateSearcher.Search("IsInstalled=0")

      If updateSearch.ResultCode <> 2 Then

      WScript.Echo "Search failed with result code", updateSearch.ResultCode
      WScript.Quit 1

      End If

      If updateSearch.Updates.Count = 0 Then

      WScript.Echo "There are no updates to install."
      WScript.Quit 2

      End If

      Set updateList = updateSearch.Updates

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

      Set update = updateList.Item(I)

      WScript.Echo "Update found:", update.Title

      Next

      WScript.Echo

      updateDownloader.Updates = updateList
      updateDownloader.Priority = 3

      Set downloadResult = updateDownloader.Download()

      If downloadResult.ResultCode <> 2 Then

      WScript.Echo "Download failed with result code", downloadResult.ResultCode
      WScript.Echo

      WScript.Quit 1

      End If

      WScript.Echo "Download complete. Installing updates ..."
      WScript.Echo

      updateInstaller.Updates = updateList

      Set installationResult = updateInstaller.Install()

      If installationResult.ResultCode <> 2 Then

      WScript.Echo "Installation failed with result code", installationResult.ResultCode

      For I = 0 to updateList.Count - 1

      Set updateInstallationResult = installationResult.GetUpdateResult(I)
      WScript.Echo "Result for " & updateList.Item(I).Title & " is " & installationResult.GetUpdateResult(I).ResultCode

      Next

      WScript.Quit 1

      End If

      If installationResult.RebootRequired Then

      WScript.Echo "The system must be rebooted to complete installation."

      WScript.Quit 3

      End If

      WScript.Echo "Installation complete."

      Loop






      windows-update vbscript






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 8 '14 at 0:41







      CS_STEM

















      asked Nov 8 '14 at 0:34









      CS_STEMCS_STEM

      65




      65





      bumped to the homepage by Community 13 mins ago


      This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







      bumped to the homepage by Community 13 mins ago


      This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
























          1 Answer
          1






          active

          oldest

          votes


















          0














          The Windows Update API is quite powerful, however it is not easy to determine which update is acutally "important" - your code shows a very simple search for all updates that are not yet installed. You can list the update packages and query the properties of the IUpdate Interfaces (see http://msdn.microsoft.com/en-us/library/windows/desktop/aa386099(v=vs.85).aspx)



          You can also have a look at WuInstall (there was a free version a while ago, but they put it off the website, now only a commercial version with a free trial is availalbe) - it does also utilize the Windows Update API in a command line tool. See http://www.wuinstall.com/ and http://help.wuinstall.com/en/index.html



          Basically, you can do many (not all) things that WuInstall can do also with the Windows Update API, but it might save you a lot of time of programming and debugging.



          What do you mean with "create a popup", by the way?






          share|improve this answer
























          • it creates multiple window in order to notify the user of any available updates. the code above does work but in order to all the updates avalible you have to update the window by clicking... not helpful with over 100 updates needed.

            – CS_STEM
            Dec 30 '14 at 14:00











          • Only message boxes will pop up when updates are available if you use this VBScript [link] (superuser.com/questions/1152177/…).

            – Matthew Wai
            Dec 13 '16 at 14:55













          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "3"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f837417%2fforce-windows-update-to-check-for-updates-with-filters-to-avoid-certain-types-of%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          The Windows Update API is quite powerful, however it is not easy to determine which update is acutally "important" - your code shows a very simple search for all updates that are not yet installed. You can list the update packages and query the properties of the IUpdate Interfaces (see http://msdn.microsoft.com/en-us/library/windows/desktop/aa386099(v=vs.85).aspx)



          You can also have a look at WuInstall (there was a free version a while ago, but they put it off the website, now only a commercial version with a free trial is availalbe) - it does also utilize the Windows Update API in a command line tool. See http://www.wuinstall.com/ and http://help.wuinstall.com/en/index.html



          Basically, you can do many (not all) things that WuInstall can do also with the Windows Update API, but it might save you a lot of time of programming and debugging.



          What do you mean with "create a popup", by the way?






          share|improve this answer
























          • it creates multiple window in order to notify the user of any available updates. the code above does work but in order to all the updates avalible you have to update the window by clicking... not helpful with over 100 updates needed.

            – CS_STEM
            Dec 30 '14 at 14:00











          • Only message boxes will pop up when updates are available if you use this VBScript [link] (superuser.com/questions/1152177/…).

            – Matthew Wai
            Dec 13 '16 at 14:55


















          0














          The Windows Update API is quite powerful, however it is not easy to determine which update is acutally "important" - your code shows a very simple search for all updates that are not yet installed. You can list the update packages and query the properties of the IUpdate Interfaces (see http://msdn.microsoft.com/en-us/library/windows/desktop/aa386099(v=vs.85).aspx)



          You can also have a look at WuInstall (there was a free version a while ago, but they put it off the website, now only a commercial version with a free trial is availalbe) - it does also utilize the Windows Update API in a command line tool. See http://www.wuinstall.com/ and http://help.wuinstall.com/en/index.html



          Basically, you can do many (not all) things that WuInstall can do also with the Windows Update API, but it might save you a lot of time of programming and debugging.



          What do you mean with "create a popup", by the way?






          share|improve this answer
























          • it creates multiple window in order to notify the user of any available updates. the code above does work but in order to all the updates avalible you have to update the window by clicking... not helpful with over 100 updates needed.

            – CS_STEM
            Dec 30 '14 at 14:00











          • Only message boxes will pop up when updates are available if you use this VBScript [link] (superuser.com/questions/1152177/…).

            – Matthew Wai
            Dec 13 '16 at 14:55
















          0












          0








          0







          The Windows Update API is quite powerful, however it is not easy to determine which update is acutally "important" - your code shows a very simple search for all updates that are not yet installed. You can list the update packages and query the properties of the IUpdate Interfaces (see http://msdn.microsoft.com/en-us/library/windows/desktop/aa386099(v=vs.85).aspx)



          You can also have a look at WuInstall (there was a free version a while ago, but they put it off the website, now only a commercial version with a free trial is availalbe) - it does also utilize the Windows Update API in a command line tool. See http://www.wuinstall.com/ and http://help.wuinstall.com/en/index.html



          Basically, you can do many (not all) things that WuInstall can do also with the Windows Update API, but it might save you a lot of time of programming and debugging.



          What do you mean with "create a popup", by the way?






          share|improve this answer













          The Windows Update API is quite powerful, however it is not easy to determine which update is acutally "important" - your code shows a very simple search for all updates that are not yet installed. You can list the update packages and query the properties of the IUpdate Interfaces (see http://msdn.microsoft.com/en-us/library/windows/desktop/aa386099(v=vs.85).aspx)



          You can also have a look at WuInstall (there was a free version a while ago, but they put it off the website, now only a commercial version with a free trial is availalbe) - it does also utilize the Windows Update API in a command line tool. See http://www.wuinstall.com/ and http://help.wuinstall.com/en/index.html



          Basically, you can do many (not all) things that WuInstall can do also with the Windows Update API, but it might save you a lot of time of programming and debugging.



          What do you mean with "create a popup", by the way?







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Dec 12 '14 at 14:28









          MacDonkeyMacDonkey

          761




          761













          • it creates multiple window in order to notify the user of any available updates. the code above does work but in order to all the updates avalible you have to update the window by clicking... not helpful with over 100 updates needed.

            – CS_STEM
            Dec 30 '14 at 14:00











          • Only message boxes will pop up when updates are available if you use this VBScript [link] (superuser.com/questions/1152177/…).

            – Matthew Wai
            Dec 13 '16 at 14:55





















          • it creates multiple window in order to notify the user of any available updates. the code above does work but in order to all the updates avalible you have to update the window by clicking... not helpful with over 100 updates needed.

            – CS_STEM
            Dec 30 '14 at 14:00











          • Only message boxes will pop up when updates are available if you use this VBScript [link] (superuser.com/questions/1152177/…).

            – Matthew Wai
            Dec 13 '16 at 14:55



















          it creates multiple window in order to notify the user of any available updates. the code above does work but in order to all the updates avalible you have to update the window by clicking... not helpful with over 100 updates needed.

          – CS_STEM
          Dec 30 '14 at 14:00





          it creates multiple window in order to notify the user of any available updates. the code above does work but in order to all the updates avalible you have to update the window by clicking... not helpful with over 100 updates needed.

          – CS_STEM
          Dec 30 '14 at 14:00













          Only message boxes will pop up when updates are available if you use this VBScript [link] (superuser.com/questions/1152177/…).

          – Matthew Wai
          Dec 13 '16 at 14:55







          Only message boxes will pop up when updates are available if you use this VBScript [link] (superuser.com/questions/1152177/…).

          – Matthew Wai
          Dec 13 '16 at 14:55




















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Super User!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f837417%2fforce-windows-update-to-check-for-updates-with-filters-to-avoid-certain-types-of%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Couldn't open a raw socket. Error: Permission denied (13) (nmap)Is it possible to run networking commands...

          VNC viewer RFB protocol error: bad desktop size 0x0I Cannot Type the Key 'd' (lowercase) in VNC Viewer...

          Why not use the yoke to control yaw, as well as pitch and roll? Announcing the arrival of...