C# 如果没有提升的权限,我无法让WUApiLib运行安装方法,Windows 10本机更新接口如何工作?

C# 如果没有提升的权限,我无法让WUApiLib运行安装方法,Windows 10本机更新接口如何工作?,c#,windows-update,wuapi,C#,Windows Update,Wuapi,我正在编写一个应用程序,可以检测、下载和安装Windows更新。但是,如果没有提升的权限,我无法让非管理员安装更新。但是,我已将本地策略配置为已启用(计算机配置>管理模板>Windows组件>Windows Update>允许非管理员接收更新通知),根据帮助,该策略将允许非管理员安装。但是,WUApiLib IUpdateInstaller::install和UpdateDownloader::download方法除非提升,否则无法工作 我们如何才能实现与本机应用程序类似的功能 需要它的人的相关

我正在编写一个应用程序,可以检测、下载和安装Windows更新。但是,如果没有提升的权限,我无法让非管理员安装更新。但是,我已将本地策略配置为已启用(计算机配置>管理模板>Windows组件>Windows Update>允许非管理员接收更新通知),根据帮助,该策略将允许非管理员安装。但是,WUApiLib IUpdateInstaller::install和UpdateDownloader::download方法除非提升,否则无法工作

我们如何才能实现与本机应用程序类似的功能

需要它的人的相关代码:

public void InstallUpdates(UpdateCollection updatesCollection)
{
    UpdateSession uSession = new UpdateSession();
    IUpdateSearcher uSearcher = uSession.CreateUpdateSearcher();
    UpdateCollection updatesToInstall = new UpdateCollection();
    UpdateDownloader downloader = uSession.CreateUpdateDownloader();
    IUpdateInstaller installer = uSession.CreateUpdateInstaller();

    foreach (IUpdate update in updatesCollection)
{
    if (update.IsDownloaded == false)
    {
        ProgramLog.LogMessageToFile("Downloading " + update.Title + "...");
        do
        {
            downloader.Updates.Add(update);
            downloader.Download();
        }
        while (update.IsDownloaded == false);
        ProgramLog.LogMessageToFile(update.Title + " downloaded");

        ProgramLog.LogMessageToFile("Adding " + update.Title + " to list of updates for installation");
        updatesToInstall.Add(update);
    }
    else
    {
        ProgramLog.LogMessageToFile(update.Title + " is already downloaded");

        ProgramLog.LogMessageToFile("Adding " + update.Title + " to list of updates for installation");
        updatesToInstall.Add(update);
    }
}

installer.Updates = updatesToInstall;

ProgramLog.LogMessageToFile("Beginning installation of " + installer.Updates.Count.ToString() + " updates");

installer.Install();

IInstallationResult installationRes = installer.Install();

for (int i = 0; i < updatesToInstall.Count; i++)
{
    ProgramLog.LogMessageToFile("Installing " + updatesToInstall[i].Title + "...");

    if (installationRes.GetUpdateResult(i).HResult == 0)
    {
        ProgramLog.LogMessageToFile(updatesToInstall[i].Title + " installed successfully!");
    }
    else
    {
        ProgramLog.LogMessageToFile("Failed to install " + updatesToInstall[i].Title);
    }
}
}
public void InstallUpdates(UpdateCollection UpdateCollection)
{
UpdateSession UseSession=新的UpdateSession();
IUpdateSearcher uSearcher=UseSession.CreateUpdateSarcher();
UpdateCollection UpdateStoreInstall=新的UpdateCollection();
UpdateDownloader downloader=uSession.CreateUpdateDownloader();
IUpdateInstaller安装程序=uSession.CreateUpdateInstaller();
foreach(更新集合中的IUpdate更新)
{
如果(update.isdownload==false)
{
ProgramLog.LogMessageToFile(“下载”+update.Title+”);
做
{
downloader.Updates.Add(更新);
downloader.Download();
}
while(update.isdownload==false);
ProgramLog.LogMessageToFile(update.Title+“已下载”);
ProgramLog.LogMessageToFile(“将“+update.Title+”添加到安装更新列表中”);
updatesToInstall.Add(更新);
}
其他的
{
ProgramLog.LogMessageToFile(update.Title+“已下载”);
ProgramLog.LogMessageToFile(“将“+update.Title+”添加到安装更新列表中”);
updatesToInstall.Add(更新);
}
}
installer.Updates=updatesToInstall;
ProgramLog.LogMessageToFile(“开始安装”+installer.Updates.Count.ToString()+“更新”);
Install.Install();
IInstallationResult installationRes=installer.Install();
对于(int i=0;i