Microsoft/Windows Updates

From Omnia
Revision as of 01:38, 26 January 2021 by Kenneth (talk | contribs) (→‎Failed Windows Updates)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Temporarily Hide Windows Update

See: wushowhide.diagcab

Use wushowhide.diagcab to hide the update.

To temporarily prevent the driver or update from being reinstalled until a new driver or updated fix is available, a troubleshooter is available that provides a user interface for hiding and showing Windows Updates and drivers for Windows 10. You can obtain and run the "Show or hide updates" troubleshooter by downloading it from the Microsoft Download Center.

Download the "Show or hide updates" troubleshooter package now. - http://download.microsoft.com/download/F/2/2/F22D5FDB-59CD-4275-8C95-1BE17BF70B21/wushowhide.diagcab

Failed Windows Updates

See Microsoft/Failed Windows Updates

VBScript Windows Update

cscript windows_update.vbs

windows_update.vbs:

'ServerSelection values 
ssDefault = 0 
ssManagedServer   = 1 
ssWindowsUpdate   = 2 
ssOthers          = 3 
 
'InStr values 
intSearchStartChar = 1 
 
dim strTitle 
 
Set updateSession = CreateObject("Microsoft.Update.Session") 
Set updateSearcher = updateSession.CreateupdateSearcher() 
 
updateSearcher.ServerSelection = ssWindowsUpdate 
Set searchResult = updateSearcher.Search("IsInstalled=0 and Type='Software'") 
 
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 
            strInput = "Y" 
            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 
strInput = "Y" 
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 

Sample:


C:\scripts>cscript wupdate.vbs
Microsoft (R) Windows Script Host Version 5.812
Copyright (C) Microsoft Corporation. All rights reserved.

List of applicable items on the machine:
1> 2020-10 Security Update for Adobe Flash Player for Windows 10 Version 1909 for x64-based Systems (KB4580325)
2> Windows Malicious Software Removal Tool x64 - v5.85 (KB890830)
3> 2021-01 Cumulative Update for .NET Framework 3.5 and 4.8 for Windows 10 Version 1909 for x64 (KB4586878)
4> Security Intelligence Update for Microsoft Defender Antivirus - KB2267602 (Version 1.329.2861.0)
5> 2020-10 Update for Windows 10 Version 1909 for x64-based Systems (KB4023057)
6> 2021-01 Cumulative Update for Windows 10 Version 1909 for x64-based Systems (KB4598229)

Creating collection of updates to download:
1> adding: 2020-10 Security Update for Adobe Flash Player for Windows 10 Version 1909 for x64-based Systems (KB4580325)
2> adding: Windows Malicious Software Removal Tool x64 - v5.85 (KB890830)
3> adding: 2021-01 Cumulative Update for .NET Framework 3.5 and 4.8 for Windows 10 Version 1909 for x64 (KB4586878)
4> adding: Security Intelligence Update for Microsoft Defender Antivirus - KB2267602 (Version 1.329.2861.0)
5> adding: 2020-10 Update for Windows 10 Version 1909 for x64-based Systems (KB4023057)
6> adding: 2021-01 Cumulative Update for Windows 10 Version 1909 for x64-based Systems (KB4598229)

Downloading updates...

Successfully downloaded updates:
1> 2020-10 Security Update for Adobe Flash Player for Windows 10 Version 1909 for x64-based Systems (KB4580325)
2> Windows Malicious Software Removal Tool x64 - v5.85 (KB890830)
3> 2021-01 Cumulative Update for .NET Framework 3.5 and 4.8 for Windows 10 Version 1909 for x64 (KB4586878)
4> Security Intelligence Update for Microsoft Defender Antivirus - KB2267602 (Version 1.329.2861.0)
5> 2020-10 Update for Windows 10 Version 1909 for x64-based Systems (KB4023057)
6> 2021-01 Cumulative Update for Windows 10 Version 1909 for x64-based Systems (KB4598229)

These updates may require a reboot.

Would you like to install updates now? (Y/N)

Installing updates...
Installation Result: 2
Reboot Required: True

Listing of updates installed and individual installation results:
1> 2020-10 Security Update for Adobe Flash Player for Windows 10 Version 1909 for x64-based Systems (KB4580325): 2
2> Windows Malicious Software Removal Tool x64 - v5.85 (KB890830): 2
3> 2021-01 Cumulative Update for .NET Framework 3.5 and 4.8 for Windows 10 Version 1909 for x64 (KB4586878): 2
4> Security Intelligence Update for Microsoft Defender Antivirus - KB2267602 (Version 1.329.2861.0): 2
5> 2020-10 Update for Windows 10 Version 1909 for x64-based Systems (KB4023057): 2
6> 2021-01 Cumulative Update for Windows 10 Version 1909 for x64-based Systems (KB4598229): 2

ref: VB Script to Check, Download, and Install Windows Updates from Microsoft https://gallery.technet.microsoft.com/scriptcenter/VB-Script-to-Check-and-620579cd

keywords

microsoft windows update updates