查询Win32_Products可能需要很长时间,当我试图查询许多计算机时,这让我感到很沮丧。我以前从未使用过MOF文件,但是有人建议用我从注册表中寻找的信息“创建”一个新的名称空间。
有人向我指出了以下MOF代码:
#PRAGMA AUTORECOVER
qualifier dynamic:ToInstance;
qualifier ProviderClsid:ToInstance;
qualifier ClassContext:ToInstance;
qualifier propertycontext:ToInstance;
[dynamic, provider("RegProv"),
ProviderClsid("{fe9af5c0-d3b6-11ce-a5b6-00aa00680c3f}"),
ClassContext
("local|HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall")
]
class Software {
[key] string KeyName;
[read, propertycontext("Publisher")] string Vendor;
[read, propertycontext("DisplayName")] string ProductName;
[read, propertycontext("DisplayVersion")] string Version;
[read, propertycontext("InstallDate")] string InstallDate;
[read, propertycontext("InstallLocation")] string InstallLocation;
[read, propertycontext("InstallSource")] string InstallSource;
[read, propertycontext("UninstallString")] string UninstallString;
};这是非常好的工作,但是如何检查软件和软件\Wow6432节点路径呢?我试过在VM上玩它,但是没有运气,只是在黑暗中刺伤。
我试过:
("local|HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall")
("local|HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall")或
("local|HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall",
"local|HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall")还有其他一些随机的想法。似乎什么都起不到作用。您将如何从两个注册表路径中收集信息?
我很感激你的帮助!这会让我的剧本少几分钟。
发布于 2015-09-16 10:53:49
要么创建两个单独的MOF文件(每个注册表路径一个),要么使用多个实例化__Win32Provider,如下所示
#PRAGMA AUTORECOVER
#pragma namespace("\\\\.\\root\\CimV2")
qualifier dynamic:ToInstance;
qualifier ProviderClsid:ToInstance;
qualifier ClassContext:ToInstance;
qualifier propertycontext:ToInstance;
Instance of __Win32Provider as $prov32bit
{
Name = "RegProv32";
// ClsId = "{fe9af5c0-d3b6-11ce-a5b6-00aa00680c3f}";
};
Instance of __Win32Provider as $prov64bit
{
Name = "RegProv64";
// ClsId = "{fe9af5c0-d3b6-11ce-a5b6-00aa00680c3f}";
};
[dynamic, provider($prov32bit),
ProviderClsid("{fe9af5c0-d3b6-11ce-a5b6-00aa00680c3f}"),
ClassContext
("local|HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall")
]
[dynamic, provider($prov64bit),
ProviderClsid("{fe9af5c0-d3b6-11ce-a5b6-00aa00680c3f}"),
ClassContext
("local|HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall")
] 非常肯定有必要将class Software部件翻一番。不确定所有ToInstance 限定符风味的正确性。最后,上面的脚本并不关心Wow6432Node的存在。然而,这个解决方案看上去不错。
这个脚本创建了一个
WMI类Win32_AddRemovePrograms(在64位系统上,为32位应用程序创建Win32_AddRemovePrograms32),它由注册表提供程序支持。然后,可以查询它们以列出已安装的应用程序(和版本),并执行比使用PowerShell注册表提供程序运行相同查询快得多的操作。此外,它们还可以用于GPO策略等。
https://stackoverflow.com/questions/32387457
复制相似问题