标签: wuapi

WUApiLib IUpdateInstaller2产生错误; 一些操作系统更新安装其他人扔HResult -2145124318

正在从本地服务器而不是从WUS或Microsoft存储库下载更新.本地服务器是基于Linux的,主机是每次更新的内容.

我不是UpdateDownloader用来从Microsoft Servers下载,我手动下载更新内容然后使用CopyToCache.

这些安装好了

Windows XP,Server 2003,Vista,Server 2008 x86上的Microsoft .NET Framework 3.5 SP1安全更新程序(KB2736416)

Microsoft Visual Studio 2010安全更新程序(KB2542054)

这些没有

XP,Server 2003,Vista,Windows 7,Server 2008 x86上的Microsoft .NET Framework 4安全更新程序(KB2840628)

Windows XP,Server 2003,Vista和Server 2008 x86上的Microsoft .NET Framework 3.5 SP1更新(KB2836940)

我的流程如何运作

我从本地服务器收到此安装,我用它来下载更新的所有下载内容.(KB2840628上面的blockquote文本是下面提供的示例)

{
  "app_uris": [
    {
      "file_name": "msipatchregfix-x86_94a84b80b8b45a1ac53a0e5d085513da0f099655.exe",
      "file_uri": "https://192.168.5.108/packages/d13c13c81f94fbb48f39c817a71ff239a31773d3a0e821a968dc42a913892841/msipatchregfix-x86_94a84b80b8b45a1ac53a0e5d085513da0f099655.exe",
      "file_size": 130600
    },
    {
      "file_name": "ndp40-kb2840628-v2-x86_891d50ff3c1322db3fb0fde222ebb0aaa5260272.exe",
      "file_uri": "https://192.168.5.108/packages/d13c13c81f94fbb48f39c817a71ff239a31773d3a0e821a968dc42a913892841/ndp40-kb2840628-v2-x86_891d50ff3c1322db3fb0fde222ebb0aaa5260272.exe",
      "file_size": 13294216
    }
  ],
  "app_id": "d13c13c81f94fbb48f39c817a71ff239a31773d3a0e821a968dc42a913892841",
  "app_name": "Security Update for Microsoft .NET Framework 4 on XP, Server 2003, Vista, Windows 7, Server 2008 …
Run Code Online (Sandbox Code Playgroud)

.net c# windows-update wuapi

7
推荐指数
1
解决办法
1345
查看次数

无法将COM对象强制转换为接口类型'WUApiLib.UpdateSession c#

我正在使用WUApiLib.dll,并编写程序来检测可以下载和安装哪些更新.

    Type t = Type.GetTypeFromProgID("Microsoft.Update.Session", "10.81.4.213");
    UpdateSession session = (UpdateSession)Activator.CreateInstance(t);

    ISearchResult SearchResults = UpdateSearchResult.Search("IsInstalled=0");
    foreach (IUpdate x in SearchResults.Updates)
    {
        Console.WriteLine(x.Title);
    }
Run Code Online (Sandbox Code Playgroud)

大部分时间它都可以正常工作,但在某些情况下,我在使用UpdateSession时遇到错误:

UpdateSession session = (UpdateSession)Activator.CreateInstance(t);
Run Code Online (Sandbox Code Playgroud)

出现以下错误:

{"Unable to cast COM object of type 'System.__ComObject' to interface type 'WUApiLib.UpdateSession'. 
This operation failed because the QueryInterface call on the COM component for the interface 
with IID '{918EFD1E-B5D8-4C90-8540-AEB9BDC56F9D}' failed due to the following error: 
The RPC server is unavailable. (Exception from HRESULT: 0x800706BA)."}
Run Code Online (Sandbox Code Playgroud)

我没有配置防火墙,因为我看到人们在关于类似错误的其他主题中说,但我不知道为什么我会收到此错误.任何想法是什么问题以及我如何解决它?

.net c# casting wuapi

6
推荐指数
1
解决办法
285
查看次数

使用C#的Windows Update API找不到任何已安装的更新

我有许多Windows 7 PC需要使用C#控制台应用程序中的Windows Update API修补特定的Windows更新.API需要搜索已安装的更新并报告它是否已安装,如果没有则执行安装.

在Virtual PC(Windows 7 Professional Hyper-v客户端)上进行测试时,我遇到类似于目标PC(Windows 7 Embedded)的情况,其中以下代码返回(非常快速且没有任何例外)0更新.我知道这是错的.事实上,它甚至在我安装.msu更新后返回.

码:

 UpdateSession uSession = new UpdateSession();
 IUpdateSearcher uSearcher = uSession.CreateUpdateSearcher();
 uSearcher.Online = false;
 try
 {
    ISearchResult sResult = uSearcher.Search("IsInstalled=1 And IsHidden=0");
    Console.WriteLine("Found " + sResult.Updates.Count + " updates");
    foreach (IUpdate update in sResult.Updates)
    {
       Console.WriteLine(update.Title);
       if (update.Title.ToLower().Contains("kb123456")) {
        //Update is not required
        ReportInstalled();
        return;
       }
     }
     //If we get here, the update is not installed
     InstallUpdate();
  }
  catch (Exception ex)
  {
    Console.WriteLine("Something went wrong: " + ex.Message);
  } …
Run Code Online (Sandbox Code Playgroud)

c# windows-services windows-update windows-7 wuapi

5
推荐指数
1
解决办法
688
查看次数

使用 PowerShell,是否可以在没有类型库或 COM 互操作 DLL 的情况下调用 IUpdateInstaller4.Commit?

这个问题本质上是一个 6 年多前的问题的后续问题:\n IUpdateInstaller4::Commit not found

\n

正如 Hans Passant 在该答案中所述,当时,不仅类型库完全缺少此接口,而且其他接口(如 IUpdateInstaller3)也完全缺少。

\n

快进到现在,Windows 10 20H2 及更高版本实际上有一个 wuapi.dll,其中包含 wuapi.dll 内的完整类型库,并且 MSDN 文档已更新。

\n

以下是 IUpdateInstaller4 接口(以及之前缺失的其余接口)的链接:\n https://learn.microsoft.com/en-us/windows/win32/api/wuapi/nn-wuapi-iupdateinstaller4

\n

也就是说,在旧版本的 Windows 10 上,如果要安装功能更新,则必须调用 IUpdateInstaller4.Commit 才能正确安装功能更新。我的观察是,如果您不这样做,您的 Windows 安装可能会回滚或使您的系统处于几乎无法使用的状态(问我是怎么知道的)。

\n

我正在寻找一种使用本机 powershell 的方法,以便能够在旧版本的 Windows 10(例如 Windows 10 1909)上调用 Commit 方法。到目前为止,我唯一成功的是在较新版本的 Windows 10 上创建 COM 互操作 DLL Windows 10(例如 21H2)并将 COM 互操作 DLL 带回 1909 计算机并利用它 -但我正在寻找一种方法来执行此操作,而无需将整个 DLL 发送到计算机。我怀疑有一种方法可以使用 Add-Type 和一些 C# 代码来完成此操作,这是我理想的解决方案,以便整个 Windows 更新过程可以由我编写的 Powershell 脚本来处理。

\n …

c# com powershell wuapi

5
推荐指数
1
解决办法
369
查看次数

获取最新的 Windows 更新检查 C++ wuapi

我正在尝试使用 wuapi 获取最后一次 Windows 更新检查。我有以下代码:

VARIANT variant;
VariantInit(&variant);

IAutomaticUpdatesResults* pAutomaticUpdatedResults = NULL;
if (pAutomaticUpdatedResults->get_LastSearchSuccessDate(&variant) != S_OK)
  throw;

std::cout << variant.date << std::endl;
Run Code Online (Sandbox Code Playgroud)

可以理解的是,我得到了一个未初始化的异常pAutomaticUpdatedResults,但我不确定使用 wuapi 的正确方法

c++ windows winapi wuapi

2
推荐指数
1
解决办法
429
查看次数