有没有人成功使用过 WMI Win32_PatchPackage 类?(C#) [英] Has anyone successfully used the WMI Win32_PatchPackage class? (C#)
问题描述
根据此处和这里,这个课程应该给我一个很好的和人性化的-适用于 Windows 的补丁的可读列表.我想要的是应用于远程机器的知识库补丁列表.
According to sources here and here, this class should give me a nice and human-readable list of patches applied to Windows. What I want is a list of KB patches applied to a remote machine.
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 的大杂烩.我是不是找错地方了?
Instead, what I get is this GUID-like smorgasbord. Am I looking for things in the wrong place?
{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...
推荐答案
就其价值而言,这正是我所看到的.我已经在 Win7 和 Vista 机器上尝试过这段代码.两者都是64位机器.两者都产生了大量的 GUID.
For what it's worth, this is exactly what I see. I've tried this code on a Win7 and a Vista mechine. Both are 64 bit machines. Both produced a sea of GUIDs.
我也尝试安装 WMI 工具...
I also tried installing the WMI Tools...
...这些显示完全相同的东西.
... and these show the exact same thing.
如果您要枚举计算机上安装的修补程序和补丁,那么您可能需要查看 Win32_QuickFixEngineering 类.如果您更改代码以便从此对象中选择...
If you're looking to enumerate the hotfixes and patches installed on the machine then you might want to look at the Win32_QuickFixEngineering class instead. If you change you code so that select from this object...
ManagementObjectSearcher searcher = new ManagementObjectSearcher(new ObjectQuery("select * from Win32_QuickFixEngineering"));
...并打印出 HotFixID 和说明...
... and print out the HotFixID and Description...
Console.WriteLine("{0}: {1} : {2} \n", queryObj["HotFixID"], queryObj["Caption"], queryObj["Description"]);
...那么你可能会得到你想要的.我看到这样的行...
... then you might get what you're after. I see rows like this...
KB975467:http://support.microsoft.com/?kbid=975467: 安全更新
KB975467: http://support.microsoft.com/?kbid=975467 : Security Update
KB975517:http://support.microsoft.com/?kbid=975517: 安全更新
KB975517: http://support.microsoft.com/?kbid=975517 : Security Update
KB976325:http://support.microsoft.com/?kbid=976325: 安全更新
KB976325: http://support.microsoft.com/?kbid=976325 : Security Update
这个页面...
http://msdn.microsoft.com/en-us/library/aa394596(VS.85).aspx
...有一些很好的样本,这个页面...
... has some good samples, and this page...
http://msdn.microsoft.com/en-us/library/aa394391(VS.85).aspx
... 描述 Win32_QuickFixEngineering 类.
... describes Win32_QuickFixEngineering class.
这篇关于有没有人成功使用过 WMI Win32_PatchPackage 类?(C#)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!