您好,我正在尝试制作一个C#应用程序,可以检查丢失的windows更新。我可以让我的代码在用户登录时工作,因为这似乎可以解决我的代理身份验证问题,但我希望它在用户登录之前在启动时运行。下面是我的代码,它在visual studio中运行良好,或者当我构建它并在另一台PC上运行时,但当我将它设置为在启动和重新启动PC时运行时,我得到的结果是"System.Runtime.InteropServices.COMException ( 0x80240438 ):Exception from HRESULT: 0x80240438 at WUApiLib.IUpdateSearcher.Search(String criteria)“。
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");发布于 2021-05-21 01:51:07
您的代理可能集成了Active Directory,不接受这种登录。
您可以尝试创建一个在所需用户的上下文中运行的计划任务,并在那里启动您的代码。
https://stackoverflow.com/questions/65882438
复制相似问题