none
WUA VB script to scan wsusscn2.cab file and fetch KB update files download url location with all .cab,.exe,.msu extensions if available RRS feed

  • General discussion

  • I am writing a VB script to find the list of missing windows updates on the host in offline mode. Means i will provide path of wsusscn2.cab file in VB script and fetch various parameters like Title,Type,Severity,download url link etc. I can find list of missing updates and their names using the script but it is always giving the URL link pointing to .cab file only even though we have same KB with extension .msu is available in microsoft catalog update website. My scope of work is to find the respective missing KB file with .msu/.msi extension and display it in the script. But my script always fetching .cab extension updates only but not both .cab and .msu for same KB even though both found in windows updates website.

    If .msu file of an update not found in wsusscan2.cab file with offline  then i need to go to microsoft update link and fetch that information using online. Any help is greatly appreciated.

    REM ************************************************************
    REM Url to download the latest offline update cab file
    REM http://go.microsoft.com/fwlink/?LinkID=74689
    REM ************************************************************
     
    ON ERROR RESUME NEXT
     
    ' Here we connect to the remote PC
    Set UpdateSession = CreateObject("Microsoft.Update.Session")
     
    Wscript.Echo "Error Number 0: " & Err.Number
    Wscript.Echo "Error Description 0: " & Err.Description
     
    ' Get the service manager and point it at the cab file
    Set UpdateServiceManager = CreateObject("Microsoft.Update.ServiceManager")
    Set UpdateService = UpdateServiceManager.AddScanPackageService("Offline Sync Service", "C:\windows\temp\wsusscn2.cab")
    Set UpdateSearcher = UpdateSession.CreateUpdateSearcher()
     
    Wscript.Echo "Error Number 1: " & Err.Number
    Wscript.Echo "Error Description 1: " & Err.Description
     
    ' Inform the searcher that it is using a different server (cab file)
    UpdateSearcher.ServerSelection = 3 ' ssOthers
    UpdateSearcher.ServiceID = UpdateService.ServiceID
    'UpdateSearcher.IncludePotentiallySupersededUpdates = true
     
    Set SearchResult = UpdateSearcher.Search("IsInstalled=0 and Type='Software'")
     
    ' HERE'S WHERE IT FAILS WHEN WE TRY TO CHECK A REMOTE COMPUTER WITH THE CAB FILE
    Wscript.Echo "Error Number 2: " & Err.Number
    Wscript.Echo "Error Description 2: " & Err.Description
     
    Set Updates = SearchResult.Updates
     
    If searchResult.Updates.Count = 0 Then
        WScript.Echo "There are no applicable updates."
        REM WScript.Quit
    End If
     
    Wscript.Echo "Total Updates: " & searchResult.Updates.Count & vbcrlf

    if updates.Count > 0 then
        For I = 0 to SearchResult.Updates.Count-1
            fs_log("I = [" & I & "]")
        
            Set update = SearchResult.Updates.Item(I)
            Set identity = update.Identity
            Set ImageInformation = update.Image
            Set BundledUpdates = update.BundledUpdates

                For J = 0 To BundledUpdates.Count - 1
                Wscript.StdOut.WriteLine "@@@@@@"
                    Set b_update = BundledUpdates.item(J)
                    Set ImageInformation = b_update.Image
                    
                    For K = 0 To b_update.DownloadContents.Count - 1
                        'fs_log("URL = [" & b_update.DownloadContents.item(K).DownloadUrl & "]")
                        Wscript.StdOut.WriteLine "URL=="
                    Next
                    
                    if Len(b_update.DownloadContents.item(K).DownloadUrl) > 0 Then
                        answerString = answerString & "|" & b_update.DownloadContents.item(0).DownloadUrl & "|"
                        Wscript.StdOut.WriteLine answerString
                        Exit For
                    End If
                Next

                ' print id of every patch that superseded by this patch
                Set SupersededUpdateIDs = update.SupersededUpdateIDs
                For J = 0 To SupersededUpdateIDs.count - 1
                    answerString = answerString & SupersededUpdateIDs.item(J) & "|"
                Next
                'WScript.Echo answerString
        Next
    end if

    • Changed type Bill_Stewart Wednesday, September 13, 2017 9:51 PM
    • Moved by Bill_Stewart Wednesday, September 13, 2017 9:51 PM This is not "fix/debug/rewrite my script for me" forum
    Thursday, August 3, 2017 3:34 PM

All replies

  • Please read the following post first:

    This forum is for scripting questions rather than script requests


    -- Bill Stewart [Bill_Stewart]

    Thursday, August 3, 2017 3:36 PM
  • Dear fellows,

    I am writing a VB script to find the list of missing windows updates on the windows system in offline mode. Means i will provide path of wsusscn2.cab file in VB script and fetch various parameters like Title,Type,Severity,download url link etc. I can find list of missing updates and their names using the script but it is always giving the URL link pointing to .cab file only even though we have same KB with extension .msu is available in microsoft catalog update website. My scope of work is to find the respective missing KB file with .msu/.msi extension and display it in the script. But my script always fetching .cab extension updates only but not both .cab and .msu for same KB even though both found in windows updates website.

    If .msu file of an update not found in wsusscan2.cab file with offline  then i need to go to microsoft update link and fetch that information using online. Any help is greatly appreciated. Following is the code snippet where im trying to get URL for .msu

     Set update = SearchResult.Updates.Item(I)
            Set identity = update.Identity
            Set ImageInformation = update.Image
            Set BundledUpdates = update.BundledUpdates

                For J = 0 To BundledUpdates.Count - 1
                    Set b_update = BundledUpdates.item(J)
                    Set ImageInformation = b_update.Image
                    
                    For K = 0 To b_update.DownloadContents.Count - 1
                     answerString = answerString & "|" & b_update.DownloadContents.item(0).DownloadUrl & "|"
                        Wscript.StdOut.WriteLine answerString
                    Next

    Any help is really appreciated.

    • Merged by Bill_Stewart Friday, August 4, 2017 8:51 PM Duplicate
    Friday, August 4, 2017 7:20 PM
  • I should also add that that file is designed to work only with MBSA and WUSA.  Install MBSA command line scanner and run a report to XML.  The XML will list all missing KBs of critical or serious level and will also list may other security issues not available through WUA.  When used with WUA only certain links are made available and I do not believe it will list modern Office updates or updates to many subsystems.  The links are to CAB file because WUSA only downloads CAB files.  You can extract te cab to get the MSU file and other support files.

    Post in MBSA forum for help in using the wsusscn2.cab with MBSA.


    \_(ツ)_/

    Friday, August 4, 2017 8:54 PM
  • Thanks for your generous reply. First i posted this in Tech forum and they suggested me to post in script forum. So i posted here. I too know that reposting will not help anything.

    Thanks you

    Friday, August 4, 2017 9:20 PM
  • Just because you have a script does not mean that someone has the time to reproduce your environment, copy and paste your code, reproduce the problem, perform debugging, and deliver a code fix for you. (Remember that the advice here is free - we are not paid Microsoft employees, and there's no SLA.)

    Also - as an aside - we would very much recommend that you leave VBScript behind and switch to PowerShell.


    -- Bill Stewart [Bill_Stewart]


    Friday, August 4, 2017 9:28 PM
  • Yes iam not expecting any one to debug or troubleshoot or replicate my problem. I just needed some information about the way to fix my problem. I guess this forum is for technical stuff related to scripting problem resolution. I know that all the advice's here are free but that doesn't mean that people can give free advices to others whatever they felt either.

    Thanks for recommendation about powershell but i have problem in my existing code and i am trying to fix that. Thanks for your free advice :)

    Friday, August 4, 2017 9:52 PM
  • The problem is not in the code. It is in the approach and in your understanding of how these tools work.  The code cannot change how WUA works. 

    Within each KB in the downloads are a set of links.  If you would download and use the PowerShell version of this you would b able to easily browse the results and see the links available.  Once you understand the structure of a download then you will be able to write the code you need.

    When a download is specified you will get a number of properties on the object returned by the searcher.  Look at the properties.  Find the MS web site for the objects and read how they work.

    If you use the PowerShell module you will be able to also easily extract the url for the associated files and documentation for the update.

    All of this is what we techs have to do.  Any new subsystem requires that we do a little homework.  If you do the homework and then use your knowledge to design a web search query you might just find that someone else has posted an answer to you issue.

    I just did a search and fund many references to extracting the URL.

    https://www.google.com/search?newwindow=1&site=&source=hp&q=wua+get+url+of+file&oq=wua+get+url+of+file&gs_l=psy-ab.3...1442.13522.0.13705.20.18.0.0.0.0.536.2856.0j6j0j1j1j2.10.0....0...1.1.64.psy-ab..10.7.1791.0..0j0i131k1j0i10k1j0i22i30k1j0i22i10i30k1j33i160k1j33i21k1.omxvW3ZibF4'


    \_(ツ)_/

    Friday, August 4, 2017 10:01 PM