/bundles/itninjaweb/img/Breadcrumb_cap_w.png
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   [ - ] Hide Comments

Comments

Please log in to comment

Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
Answer this question or Comment on this question for clarity

Answers

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
Answered 07/07/2009 by: hks7mgt
Senior Yellow Belt

Please log in to comment
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
Answered 07/28/2009 by: elgwhoppo
Senior Purple Belt

Please log in to comment