将WMI查询合并为一行

时间:2014-09-07 21:22:58

标签: c# wmi

当我在本地用户和组中修改用户或用户组时,我希望检测使用WMI事件。下面是两个有效的查询。我如何将它们组合成一个查询?我尝试了or操作数,但WMI代码创建者抛出了无效的查询异常。

工作检测用户组修改

"SELECT * FROM __InstanceOperationEvent WITHIN 1 WHERE TargetInstance ISA 'Win32_Group'"

工作检测用户修改

"SELECT * FROM __InstanceOperationEvent WITHIN 1 WHERE TargetInstance ISA 'Win32_GroupUser'"

不工作 - 这就是我试过的

"SELECT * FROM __InstanceOperationEvent WITHIN 1 WHERE TargetInstance ISA 'Win32_Group' or SELECT * FROM __InstanceOperationEvent WITHIN 1 WHERE TargetInstance ISA 'Win32_GroupUser'");

2 个答案:

答案 0 :(得分:1)

试试这个:

SELECT * FROM __InstanceOperationEvent WITHIN 1
WHERE (TargetInstance ISA 'Win32_Group') OR (TargetInstance ISA 'Win32_GroupUser')

答案 1 :(得分:1)

试试这个(我认为需要的是parens):

SELECT * FROM __InstanceOperationEvent WITHIN 1 
WHERE (TargetInstance ISA 'Win32_Group' OR TargetInstance ISA 'Win32_GroupUser')