How to programmably perform windows update using WUA API with a msu file

Sachdeva, Vivek [VISUS Non-J&J] 0 Reputation points
2023-08-29T19:01:03.83+00:00

Hello,

I want to perform windows update using a *.msu file location and WUA API. I have found code where updates are fetched automatically in the following links

https://cplusplus.com/forum/windows/82125/

Also seen code where updates are searched ....but if I have the *.msu at a specific location can I use that file as an IUpdate handle?

Windows
Windows
A family of Microsoft operating systems that run across personal computers, tablets, laptops, phones, internet of things devices, self-contained mixed reality headsets, large collaboration screens, and other devices.
5,609 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Limitless Technology 44,421 Reputation points
    2023-08-31T07:56:29.6066667+00:00
    Hello there,
    
    Unfortunately librarys like Microsoft.Deployment.WindowsInstaller.dll dont work with MSU files so we're out of luck with the "off-the-shelf" options. Therefore you have to do it manually with code and the (msu.xml) XML file:
    
    <Updates>
      <UpdateIdentity UpdateID="E6CF1350-C01B-414D-A61F-263D14D133B4" RevisionNumber="1" />
      <Properties UpdateType="Category" />
      <ApplicabilityRules>
        <IsInstalled>
          <True />
        </IsInstalled>
      </ApplicabilityRules>
      <UpdateIdentity UpdateID="2bf7ed9c-6f43-493a-b156-db20f08c44c4" RevisionNumber="101" />
      <Properties UpdateType="Detectoid" />
      <Relationships />
      <ApplicabilityRules>
        <IsInstalled>
          <b.RegSz Key="HKEY_LOCAL_MACHINE" Subkey="SYSTEM\CurrentControlSet\Control\Nls\Language" Value="InstallLanguage" Comparison="EqualTo" Data="0409" />
        </IsInstalled>
      </ApplicabilityRules>
      <UpdateIdentity UpdateID="6AECE9A4-19E3-4BC7-A20C-070A5E31AFF4" RevisionNumber="100" />
      <Properties UpdateType="Detectoid" />
      <Relationships></Relationships>
      <UpdateIdentity UpdateID="3B4B8621-726E-43A6-B43B-37D07EC7019F" />
      <ApplicabilityRules>
        <IsInstalled>
          <b.WmiQuery Namespace="root\cimv2" WqlQuery="SELECT Manufacturer FROM Win32_ComputerSystem WHERE Manufacturer = 'Dell Inc.' or Manufacturer = 'Samsung Electronics' or Manufacturer = 'Hewlett-Packard' or Manufacturer = 'Gateway'" />
        </IsInstalled>
      </ApplicabilityRules>
    </Updates>
    
    
    Hope this resolves your Query !!
    
    --If the reply is helpful, please Upvote and Accept it as an answer--
    
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.