首页 > 解决方案 > 代理后面的 C# UpdateSession (WUApi.dll)

问题描述

您好我正在尝试制作一个可以检查丢失的 Windows 更新的 C# 应用程序。当用户登录时,我可以让我的代码工作,因为这似乎解决了我的代理身份验证问题,但我希望它在用户登录之前在启动时运行。下面是我的代码,它在 Visual Studio 或当我构建它并在另一台PC上运行但是当我将它设置为在启动时运行并重新启动PC时,我得到的只是“System.Runtime.InteropServices.COMException(0x80240438):HRESULT的异常:WUApiLib.IUpdateSearcher.Search的0x80240438(字符串标准)"

            IUpdateSession uSession = new UpdateSession();

            uSession.WebProxy.AutoDetect = false;
            uSession.WebProxy.Address = "http://ipAddress:port";
            uSession.WebProxy.UserName = @"Domain\user";
            string password = "password";
            uSession.WebProxy.SetPassword(password);

            IUpdateSearcher uSearcher = uSession.CreateUpdateSearcher();
            ISearchResult uResult = uSearcher.Search("IsInstalled=0");

标签: c#proxywindows-updatewuapi

解决方案


您的代理可能集成了 Active Directory,并且不接受这种登录。

您可以尝试创建一个在所需用户的上下文中运行的计划任务并在那里启动您的代码。


推荐阅读