我正在尝试使用Windows Update Agent API确定WSUS是否管理当前计算机。目前,我的代码查看了使用Windows Update Agent注册的所有服务。
private static bool IsManagedByWSUS(WUApiNativeMethods.IUpdateSession3 session)
{
WUApiNativeMethods.IUpdateServiceManager serviceManager = session.CreateUpdateServiceManager();
WUApiNativeMethods.IUpdateServiceCollection services = serviceManager.Services;
foreach (WUApiNativeMethods.IUpdateService service in services)
{
// Indicates whether the service is registered with automatic updates
var registeredWithAu = service.IsRegisteredWithAU();
// Indicates whether the service is a managed service
var isManaged = service.IsManaged();
var name = service.Name().ToLower();
if (registeredWithAu &&
isManaged &&
name.Contains("windows server update service"))
{
return true;
}
}
return false;
}
问题是我不知道检查名称是否可靠。我看到IUpdateService对象上有一个guid的服务id字段。我测试了几个盒子,似乎总是3da21691-e39d-4da6-8a4b-b43877bcb1b7。
如何可靠地检查WSUS?
答案 0 :(得分:0)
您可以检查注册表文件:HKLM \ SOFTWARE \ Policies \ Microsoft \ Windows \ WindowsUpdate
shell命令:
reg query "HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate"