Discussion:
WMI Filter by Software
(too old to reply)
Joe V
2008-11-04 16:58:54 UTC
Permalink
Hello,

I know how to setup a WMI filter so that if a certain application is
installed on the machine the GPO will run.
ex. Select * From Win32_Product Where name = "Software Name"

But how do I setup a WMI filter so that if the software is installed
the GPO will NOT run? Is there a way to do this? You have to write
the query in a way that won't return any results if it gets a match,
but I don't know how to do that.

Any help would be appreciated.

Thank you,
Joe
Florian Frommherz [MVP]
2008-11-04 17:44:53 UTC
Permalink
Joe,
Post by Joe V
I know how to setup a WMI filter so that if a certain application is
installed on the machine the GPO will run.
ex. Select * From Win32_Product Where name = "Software Name"
But how do I setup a WMI filter so that if the software is installed
the GPO will NOT run? Is there a way to do this? You have to write
the query in a way that won't return any results if it gets a match,
but I don't know how to do that.
You can't use WMI here, really. Two approaches here:
(1) Use a script to look for the application with something like IF
EXIST and then provide the path to an executable or something like this.
(2) depending on what you are trying to achieve, you can use Group
Policy Preferences with item-level targetting. That's able to run based
on files existing on the machine.

cheers,

Florian
--
Microsoft MVP - Group Policy
eMail: prename [at] frickelsoft [dot] net.
blog: http://www.frickelsoft.net/blog.
Maillist (german): http://frickelsoft.net/cms/index.php?page=mailingliste
Richard Mueller [MVP]
2008-11-04 18:13:16 UTC
Permalink
Post by Joe V
Hello,
I know how to setup a WMI filter so that if a certain application is
installed on the machine the GPO will run.
ex. Select * From Win32_Product Where name = "Software Name"
But how do I setup a WMI filter so that if the software is installed
the GPO will NOT run? Is there a way to do this? You have to write
the query in a way that won't return any results if it gets a match,
but I don't know how to do that.
Any help would be appreciated.
Thank you,
Joe
First, the product name should be enclosed in single quotes. For example:
=========
strProduct = "Software Name"
Set colSoftware = objWMIService.ExecQuery _
("SELECT * FROM Win32_Product WHERE Name = '" & strProduct & "'")
=======
Or, without the extra variable:
=======
Set colSoftware = objWMIService.ExecQuery _
("SELECT * FROM Win32_Product WHERE Name = 'Software Name'")
=======
I cannot think if a WMI query that will only return a result if the product
is not found. However a script can check the resultant recordset. In
VBScript you can assign a boolean value indicating if the product is
installed. For example:
========
blnInstalled = False
For Each objSoftware In colSoftware
blnInstalled = True
Next
=======
Then you can use this boolean later to decide what to do. Does this help?
--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--
Joe V
2008-11-04 18:42:29 UTC
Permalink
I know how to do it with a script, I was hoping to avoid that and just
use a WMI filter. I had a feeling it wasn't possible but I don't know
enough about WMI filters in a GPO to be sure. I thought maybe there
was something I was missing. Oh well.

Thanks anyway.
Joe V
2008-11-04 18:55:47 UTC
Permalink
I know how to do it with a script, I was hoping to avoid that and just
use a WMI filter. I guess there is no way to not return a result when
you get a match. Not happy about that.

Thank you anyway.

Loading...