我有 Windows Server 2012R2 的测试环境,在 Windows 7 SP1 的域中运行域控制器和客户端。
我使用此代码从客户端获取已安装软件的列表:
ManagementScope scope = new ManagementScope("\\\\10.0.0.101\\root\\cimv2");
scope.Connect();
ObjectQuery query = new ObjectQuery("SELECT * FROM Win32_Product Where AssignmentType = 1");
ManagementObjectSearcher searcher = new ManagementObjectSearcher(scope, query);
ManagementObjectCollection queryCollection = searcher.Get();
foreach (ManagementObject item in queryCollection)
{
Console.WriteLine("Name: " + item["Name"].ToString());
Console.WriteLine("PackageName: " + item["PackageName"].ToString());
Console.WriteLine("PackageCode: " + item["PackageCode"].ToString());
}
我的问题是,在将客户端加入域之前,我只获得了在客户端上安装的软件列表。连接到域后,客户端上安装了任何东西,我在查询中看不到它。