/build/static/layout/Breadcrumb_cap_w.png

Uninstalling using BOTH 'DisplayName' and 'DisplayVersion'

I have a pre-done script that searches for a DisplayName from the Registry 'HKLM\Software\MS\Windows\CV\Uninstall\<Prod Code>\DisplayName' and if it finds successful, it runs a command, generally the uninstall command.

I would like to add to the script to search for the DisplayName and DisplayVersion and if BOTH are correct, then to run a command line. Here is the code to search for the ONLY the DisplayName;


option explicit
on error resume next

dim objShell
dim strComputer
dim objWMIService
dim colSoftware
dim objProduct
dim intResult

strComputer = "." ' Local computer
intResult = 0 ' Setup for correct error handling

' Create connection to WMI and query for all programs installed
set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
set colSoftware = objWMIService.ExecQuery("SELECT * FROM Win32_Product")

Set objShell= CreateObject("Wscript.Shell")

' This information can be found in the registry. Look under the Key
' [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall]

for each objProduct in colSoftware
Select Case objProduct.Name
Case "Adobe Shockwave Player"
intResult = objShell.run("MsiExec.exe /x {A7DB362E-16DC-4E29-8A34-E74381E00B5B} ALLUSERS=1 REBOOT=REALLYSUPPRESS /qn",0,true)
End Select
if intResult <> 0 then
wscript.quit (intResult)
End if
next

0 Comments   [ + ] Show comments

Answers (2)

Posted by: hks7mgt 15 years ago
Senior Yellow Belt
0
never mind, i just duplicated the script as follows;


option explicit
on error resume next

dim objShell
dim strComputer
dim objWMIService
dim colSoftware
dim objProduct
dim intResult

strComputer = "." ' Local computer
intResult = 0 ' Setup for correct error handling

' Create connection to WMI and query for all programs installed
set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
set colSoftware = objWMIService.ExecQuery("SELECT * FROM Win32_Product")

Set objShell= CreateObject("Wscript.Shell")

' This information can be found in the registry. Look under the Key
' [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall]

for each objProduct in colSoftware
Select Case objproduct.version
Case "10.1.4.20"
intResult = objShell.run("MsiExec.exe /X {43BFB9E2-169C-46A9-BB81-141A37FD9750}} ALLUSERS=1 REBOOT=REALLYSUPPRESS /qn",0,true)
End Select
if intResult <> 0 then
wscript.quit (intResult)
End if

Select Case objproduct.version
Case "10.1.4.020"
intResult = objShell.run("MsiExec.exe /x {A7DB362E-16DC-4E29-8A34-E74381E00B5B} ALLUSERS=1 REBOOT=REALLYSUPPRESS /qn",0,true)
End Select
if intResult <> 0 then
wscript.quit (intResult)
End if

next
Posted by: elgwhoppo 15 years ago
Senior Purple Belt
0
Another way to do it is nested IF staements, less code. Logic like:

If displayname = Adobe Reader
If displayversion = 6.0
run uninstall
end if
end if
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ