c# - 代理后面的 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");
解决方案
您的代理可能集成了 Active Directory,并且不接受这种登录。
您可以尝试创建一个在所需用户的上下文中运行的计划任务并在那里启动您的代码。
推荐阅读
- spring-integration - 使用 Spring Integration 读取文件并希望使用过滤器进行排序和文件提取
- mysql - MySQL在选择时只得到一行重复的结果
- python - 创建空间相关噪声的更快方法?
- android - 如何在 Flutter 应用中正确设置 redirect_uri?
- ios - 如果 Chromecast 是内置电视,则无法检测到它
- python - django - 休息框架响应内容协商没有发生
- dataframe - 在R中,当x和y重复时,我想提取z的最小值
- google-apps-script - 进程运行时在 Google 表格桌面和移动应用中添加警告或信息消息的问题
- android - 键盘出现时如何阻止EditText向上移动
- python - 没有 if 但有 else 的列表理解