根据来源here和here,这个类应该给我一个很好的,人类可读的应用于Windows的补丁列表。我想要的是应用于远程机器的KB补丁列表。
ManagementScope scope;
ConnectionOptions options = new ConnectionOptions();
options.Username = tbUsername.Text;
options.Password = tbPassword.Password;
options.Authority = String.Format("ntlmdomain:{0}", tbDomain.Text);
scope = new ManagementScope(String.Format("\\\\{0}\\root\\cimv2", tbHost.Text), options);
scope.Connect();
ManagementObjectSearcher searcher = new ManagementObjectSearcher(scope, new ObjectQuery("SELECT * FROM Win32_PatchPackage"));
foreach (ManagementObject queryObj in searcher.Get())
{
wmiResults.Text += String.Format("{0}: {1} {2}\n",
queryObj["PatchID"],
queryObj["Caption"],
queryObj["Description"]);
}
相反,我得到的是这个像GUID一样的自助餐。我在错误的地方寻找东西吗?
{0B36C6D6-F5D8-4EAF-BF94-4376A230AD5B}: {0B36C6D6-F5D8-4EAF-BF94-4376A230AD5B} {0B36C6D6-F5D8-4EAF-BF94-4376A230AD5B}
{3D019598-7B59-447A-80AE-815B703B84FF}: {3D019598-7B59-447A-80AE-815B703B84FF} {3D019598-7B59-447A-80AE-815B703B84FF}
{5ECEB317-CBE9-4E08-AB10-756CB6F0FB6C}: {5ECEB317-CBE9-4E08-AB10-756CB6F0FB6C} {5ECEB317-CBE9-4E08-AB10-756CB6F0FB6C}
{69F52148-9BF6-4CDC-BF76-103DEAF3DD08}: {69F52148-9BF6-4CDC-BF76-103DEAF3DD08} {69F52148-9BF6-4CDC-BF76-103DEAF3DD08}
{71127777-8B2C-4F97-AF7A-6CF8CAC8224D}: {71127777-8B2C-4F97-AF7A-6CF8CAC8224D} {71127777-8B2C-4F97-AF7A-6CF8CAC8224D}
{7559E742-FF9F-4FAE-B279-008ED296CB4D}: {7559E742-FF9F-4FAE-B279-008ED296CB4D} {7559E742-FF9F-4FAE-B279-008ED296CB4D}
...etc...
答案 0 :(得分:1)
对于它的价值,这正是我所看到的。我在Win7和Vista机器上试过这个代码。两者都是64位机器。两者都产生了大量的GUID。
我也尝试过安装WMI工具......
......这些显示的完全一样。
如果您想要枚举计算机上安装的修补程序和修补程序,那么您可能需要查看 Win32_QuickFixEngineering 类。如果您更改了代码,则从该对象中选择...
ManagementObjectSearcher searcher = new ManagementObjectSearcher(new ObjectQuery("select * from Win32_QuickFixEngineering"));
...并打印出HotFixID和说明...
Console.WriteLine("{0}: {1} : {2} \n", queryObj["HotFixID"], queryObj["Caption"], queryObj["Description"]);
...那么你可能得到你想要的东西。我看到这样的行...
KB975467: http://support.microsoft.com/?kbid=975467 :安全更新
KB975517: http://support.microsoft.com/?kbid=975517 :安全更新
KB976325: http://support.microsoft.com/?kbid=976325 :安全更新
此页面......
http://msdn.microsoft.com/en-us/library/aa394596(VS.85).aspx
...有一些很好的样本,这个页面......
http://msdn.microsoft.com/en-us/library/aa394391(VS.85).aspx
...描述了Win32_QuickFixEngineering类。