尝试使用C#远程使用WUA时出错

时间:2014-08-13 08:06:09

标签: c# connection updates windows-update

我想使用WUA远程检查多个服务器的更新,以便我可以用我的程序更新它们(这将节省我很多时间)。我看到了几个这样的解决方案:

Type t = Type.GetTypeFromProgID("Microsoft.Update.Session", "XXX.XXX.XXX.XXX");
UpdateSession session = (UpdateSession)Activator.CreateInstance(t);
IUpdateSearcher updateSearcher = session.CreateUpdateSearcher();
int count = updateSearcher.GetTotalHistoryCount();
IUpdateHistoryEntryCollection history = updateSearcher.QueryHistory(0, count);
for (int i = 0; i < count; ++i)
    Console.WriteLine(string.Format("Title: {0}\tDate: {1}\r\n", history[i].Title, history[i].Date));

但是,一旦我尝试(UpdateSession)Activator.CreateInstance(t); 我得到一个COMException。我也质疑这个解决方案,因为如果我想连接remoly我通常必须有用户名,密码和服务器名。

0 个答案:

没有答案