查詢Win32_Products可能需要很長時間,而當試圖查詢大量計算機時,這讓我感到沮喪。我從來沒有使用MOF文件,但有人建議「創建」一個新的命名空間,只是從註冊表中尋找信息。帶有兩個註冊表鍵路徑的WMI 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;
};
這工作太棒了,但我怎麼能有這樣的檢查同時軟件和軟件\ Wow6432Node路徑?我曾嘗試在虛擬機上玩過它,但沒有運氣只是在黑暗中刺傷。
我想:
("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")
和其他一些隨機的想法。似乎沒有任何工作。你將如何從兩個註冊表路徑收集信息?
我將不勝感激任何幫助!這會讓我的腳本關閉幾分鐘。
謝謝您的回覆。其實我只是創建了兩個單獨的MOF文件。在一個命名空間中同時收集32位和64位軟件本來就不錯,但也可以單獨使用。 –
On:「不確定所有ToInstance限定符的風格是否正確。」:DMTF規範在CIM-XML規範中有ToInstance,它在DSP0201 2.4中棄用,但從未在DSP0004中進行過描述。所以在這一點上,ToInstance是微軟特有的風格(如Amended,NotToInstance和NotToSubClass)。 –