Discussion:
Using WMI Scripting to Uninstall Acrobat Reader using Win32_Produc
(too old to reply)
bhall
2006-11-21 15:01:02 UTC
Permalink
Hello!

I'm trying to remove all versions of Adobe Acrobat Reader where the name
matches "Adobe Reader" except for "Adobe Reader for Pocket PC".

The following script works to uninstall everything matching "Adobe Reader":
---------------------------------
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colSoftware = objWMIService.ExecQuery _
("Select * from Win32_Product Where Name LIKE '%Adobe Reader%'")
For Each objSoftware in colSoftware
objSoftware.Uninstall()
Next
---------------------------------

However, I can't figure out how to exclude everything matching "Adobe Reader
for Pocket PC". I tried doing something like:
---------------------------------
("Select * from Win32_Product Where Name LIKE '%Adobe Reader%' AND NOT LIKE
'%Adobe Reader for Pocket PC%'")
---------------------------------

But that didn't work. When using WQL queries, it seems that it is difficult
if not impossible to exclude a string from your query. If anyone else has
any insights, please share. I found the following links somewhat helpful,
although I'm still not sure how to tackle this:
http://www.microsoft.com/technet/scriptcenter/topics/win2003/like.mspx,
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/like_operator.asp

Thanks in advance!
asdf
2006-11-22 08:44:27 UTC
Permalink
Remove/Rename that install folder e.g. Program Files.

run regclean.exe

----------------------
Post by bhall
Hello!
I'm trying to remove all versions of Adobe Acrobat Reader where the name
matches "Adobe Reader" except for "Adobe Reader for Pocket PC".
---------------------------------
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colSoftware = objWMIService.ExecQuery _
("Select * from Win32_Product Where Name LIKE '%Adobe Reader%'")
For Each objSoftware in colSoftware
objSoftware.Uninstall()
Next
---------------------------------
However, I can't figure out how to exclude everything matching "Adobe Reader
---------------------------------
("Select * from Win32_Product Where Name LIKE '%Adobe Reader%' AND NOT LIKE
'%Adobe Reader for Pocket PC%'")
---------------------------------
But that didn't work. When using WQL queries, it seems that it is difficult
if not impossible to exclude a string from your query. If anyone else has
any insights, please share. I found the following links somewhat helpful,
http://www.microsoft.com/technet/scriptcenter/topics/win2003/like.mspx,
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/like_operator.asp
Post by bhall
Thanks in advance!
asdf
2006-11-22 09:03:58 UTC
Permalink
Not Program Files.

But subfolder e.g. darn stupid c:\Program Files\IamWithStupid\woah.exe

---------------

run regclean


http://search.microsoft.com/results.aspx?q=regclean&l=en&OtherSite=&mkt=en-US&FORM=QBMA
Post by asdf
Remove/Rename that install folder e.g. Program Files.
run regclean.exe
----------------------
Post by bhall
Hello!
I'm trying to remove all versions of Adobe Acrobat Reader where the name
matches "Adobe Reader" except for "Adobe Reader for Pocket PC".
The following script works to uninstall everything matching "Adobe
---------------------------------
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer &
"\root\cimv2")
Post by asdf
Post by bhall
Set colSoftware = objWMIService.ExecQuery _
("Select * from Win32_Product Where Name LIKE '%Adobe Reader%'")
For Each objSoftware in colSoftware
objSoftware.Uninstall()
Next
---------------------------------
However, I can't figure out how to exclude everything matching "Adobe
Reader
Post by bhall
---------------------------------
("Select * from Win32_Product Where Name LIKE '%Adobe Reader%' AND NOT
LIKE
Post by bhall
'%Adobe Reader for Pocket PC%'")
---------------------------------
But that didn't work. When using WQL queries, it seems that it is
difficult
Post by bhall
if not impossible to exclude a string from your query. If anyone else has
any insights, please share. I found the following links somewhat helpful,
http://www.microsoft.com/technet/scriptcenter/topics/win2003/like.mspx,
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/like_operator.asp
Post by asdf
Post by bhall
Thanks in advance!
bhall
2006-11-22 14:21:28 UTC
Permalink
I forgot to mention that this is a script that will be deployed to hundreds
of machines to pull off all previous versions of Acrobat Reader, and then run
the install script for the new version.

With all due respect, deleting the program files folder and running regclean
is a less-than-graceful solution.

I actually was able to get this script to uninstall all previous versions of
Adobe Reader by using a series of wildcard "OR" statements in the WQL query:

-------------------------------------
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colSoftware = objWMIService.ExecQuery _
("Select * from Win32_Product Where Name LIKE '%Adobe Reader____' OR
Name LIKE '%Adobe Reader______' OR Name LIKE '%Adobe Reader______ Language
Support' OR Name LIKE '%and Reader_______Update%'")

For Each objSoftware in colSoftware
objSoftware.Uninstall()
Next
-------------------------------------

This way, it will look for various possibilities or variations on the name
of the product installed and uninstall.

It's too bad there doesn't seem to be a way to simply add a "NOT LIKE" in
the WQL query to exclude a string from the search.

-bhall
Trevor Sullivan
2006-11-22 20:42:19 UTC
Permalink
Post by bhall
I forgot to mention that this is a script that will be deployed to hundreds
of machines to pull off all previous versions of Acrobat Reader, and then run
the install script for the new version.
With all due respect, deleting the program files folder and running regclean
is a less-than-graceful solution.
I actually was able to get this script to uninstall all previous versions of
-------------------------------------
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colSoftware = objWMIService.ExecQuery _
("Select * from Win32_Product Where Name LIKE '%Adobe Reader____' OR
Name LIKE '%Adobe Reader______' OR Name LIKE '%Adobe Reader______ Language
Support' OR Name LIKE '%and Reader_______Update%'")
For Each objSoftware in colSoftware
objSoftware.Uninstall()
Next
-------------------------------------
This way, it will look for various possibilities or variations on the name
of the product installed and uninstall.
It's too bad there doesn't seem to be a way to simply add a "NOT LIKE" in
the WQL query to exclude a string from the search.
-bhall
Hello,

I would run a more generic query on WMI, such as "Select * From
Win32_Product Where Name LIKE '%Adobe%'" and then use the built-in
VBscript string manipulation functions to search for other keywords.

set products = GetObject("winmgmts:Win32_Product").Instances_

for each product in products
if instr(product.name, "Adobe") <> 0 then
if instr(product.name, "Pocket") then
'skip uninstall
else
product.uninstall()
end if
end if
next

Hope this helps give you the jist of what I am getting at.
www.w3schools.org is a great place for VBscript's built-in function
documentation, but instr is probably the most helpful. If it doesn't
find the string you specify as the 2nd argument in the first argument
you supply, it returns 0.

Trevor Sullivan
MCP
bhall
2006-11-24 19:39:02 UTC
Permalink
Trevor,

That's a great idea. I'll have to try that out and see if that works. I
appreciate the reply!

-bhall
Post by Trevor Sullivan
Post by bhall
I forgot to mention that this is a script that will be deployed to hundreds
of machines to pull off all previous versions of Acrobat Reader, and then run
the install script for the new version.
With all due respect, deleting the program files folder and running regclean
is a less-than-graceful solution.
I actually was able to get this script to uninstall all previous versions of
-------------------------------------
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colSoftware = objWMIService.ExecQuery _
("Select * from Win32_Product Where Name LIKE '%Adobe Reader____' OR
Name LIKE '%Adobe Reader______' OR Name LIKE '%Adobe Reader______ Language
Support' OR Name LIKE '%and Reader_______Update%'")
For Each objSoftware in colSoftware
objSoftware.Uninstall()
Next
-------------------------------------
This way, it will look for various possibilities or variations on the name
of the product installed and uninstall.
It's too bad there doesn't seem to be a way to simply add a "NOT LIKE" in
the WQL query to exclude a string from the search.
-bhall
Hello,
I would run a more generic query on WMI, such as "Select * From
Win32_Product Where Name LIKE '%Adobe%'" and then use the built-in
VBscript string manipulation functions to search for other keywords.
set products = GetObject("winmgmts:Win32_Product").Instances_
for each product in products
if instr(product.name, "Adobe") <> 0 then
if instr(product.name, "Pocket") then
'skip uninstall
else
product.uninstall()
end if
end if
next
Hope this helps give you the jist of what I am getting at.
www.w3schools.org is a great place for VBscript's built-in function
documentation, but instr is probably the most helpful. If it doesn't
find the string you specify as the 2nd argument in the first argument
you supply, it returns 0.
Trevor Sullivan
MCP
n***@yahoo.com
2006-12-13 19:52:26 UTC
Permalink
Hey,

If you don't already have a "NOT LIKE" solution try this in your query;

"~OR Name LIKE [^Adobe Reader for Pocket PC]%'")

the up carat (^) inside the brackets followed by the Name string and
boolean is the same as a NOT LIKE/skip. Be sure of the Name string
content as you try to match a string to skip. Note that the query acts
funny, depending on how it's constructed and which string order you
use. Sometimes it's best to use two separate queries.

Good Luck
Post by bhall
I forgot to mention that this is a script that will be deployed to hundreds
of machines to pull off all previous versions of Acrobat Reader, and then run
the install script for the new version.
With all due respect, deleting the program files folder and running regclean
is a less-than-graceful solution.
I actually was able to get this script to uninstall all previous versions of
-------------------------------------
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colSoftware = objWMIService.ExecQuery _
("Select * from Win32_Product Where Name LIKE '%Adobe Reader____' OR
Name LIKE '%Adobe Reader______' OR Name LIKE '%Adobe Reader______ Language
Support' OR Name LIKE '%and Reader_______Update%'")
For Each objSoftware in colSoftware
objSoftware.Uninstall()
Next
-------------------------------------
This way, it will look for various possibilities or variations on the name
of the product installed and uninstall.
It's too bad there doesn't seem to be a way to simply add a "NOT LIKE" in
the WQL query to exclude a string from the search.
-bhall
Loading...