viewpoint-particle

Author Topic: Just playing around - Windows Updates  (Read 81 times)

stanl

  • Pundit
  • *****
  • Posts: 970
Just playing around - Windows Updates
« on: December 28, 2019, 07:27:43 am »
Code: Winbatch

;Winbatch 2019B - Windows Update Helper - no error handler
;code not complete, just a starting point for COM Objects
;Stan Littlefield, December 28,2019
;========================================================================================
updateSession = CreateObject("Microsoft.Update.Session")
updateSearcher = updateSession.CreateUpdateSearcher()
updatestoInstall = CreateObject("Microsoft.Update.UpdateColl")
BoxOpen("Update Session Objects","Initiated")
upds = updateSearcher.Search("IsInstalled=1 and Type='Software'").Updates


For i = 0 To upds.Count-1
    upd= upds.Item(i)
    Boxtext("Update ":i+1:" ":upd.Title) ; or save to file or shown in grid
    TimeDelay(1)
Next


;====== this section to be tested ======================================
;create a similar collection for not installed
;upds = updateSearcher.Search("IsInstalled=0 and Type='Software'").Updates
;If upds.Count==0
;   BoxText("No Updates pending install"0
;Else
;   BoxText("Preparing Downloads")
;   For i = 0 To upds.Count-1
;      upd= upds.Item(i)
;      updatestoInstall.Add(upd)
;   Next
;  downloader= updateSession.CreateUpdateDownloader()
;  downloader.Updates =  updatestoInstall
;  downloader.Download()
;Endif


updateSession=0
updateSearcher=0
updatestoInstall=0
Exit
 

kdmoyers

  • Sr. Member
  • ****
  • Posts: 293
Re: Just playing around - Windows Updates
« Reply #1 on: December 30, 2019, 06:18:00 am »
Cool !   I sometimes wonder if we shouldn't be controlling updates better.  This shows a beginning.
thanks!
The mind is everything; What you think, you become.

stanl

  • Pundit
  • *****
  • Posts: 970
Re: Just playing around - Windows Updates
« Reply #2 on: December 30, 2019, 12:35:31 pm »
Thanks. I'm tweaking it to include the Date, Description, and level of severity. The collection to download section works but would probably want it as user select. I also read you can add a remote PC to the CreateObject().