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
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)
Please log in to answer
Posted by:
hks7mgt
15 years ago
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
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
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
so that the conversation will remain readable.