HELP! [:o] Being really new to the scripting world, I've been racking my brain on how to write a vbscript that would check for the existance of an application in the registry. If the application exists, then have it run the UNINSTALL STRING that is associated with the app. I've got the script to atleast echo the results of what is installed, but cannot seem to get it to kick of the UNINSTALL STRING. Basically I need the script to check for an app (from within the registry) then uninstall the cotton-pickin' thing! LOL! [8|] ANY help would be greatly appreciated!!!! Thanks a million scripting pals! Have a good one!
0 Comments   [ - ] Hide 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


Hello strakm,

How do you query the registry for the list of installed applications?

If you use WMI to query the installed applications on a computer, you can also uninstall the application this way.
Answered 02/21/2005 by: brenthunter2005
Fifth Degree Brown Belt

Please log in to comment
For an MSI based installation, this might work:

Const sPARTIALPRODNAME = "Partial App Name"


Set oInstaller = Wscript.CreateObject("WindowsInstaller.Installer")

Set oProducts = oInstaller.Products

For Each sProdCode in oProducts

sProdName = oInstaller.ProductInfo(sProdCode, "ProductName")

iFindPos = Instr(LCase(sProdName), LCase(sPARTIALPRODNAME))

If iFindPos <> 0 Then oInstaller.ConfigureProduct sProdCode, 0, msiINSTALLSTATEABSENT : Exit For


Set oProducts = Nothing
Set oInstaller = Nothing
Answered 02/21/2005 by: WiseUser
Fourth Degree Brown Belt

Please log in to comment
Here's an old script I found on my hard drive - I think it does what you're looking to do? It probably needs tidying up a bit, and it won't look to pretty once I've posted it because the indentation will be lost!

Dim oWsh : Set oWsh = CreateObject("Wscript.Shell")

UninstallProduct "Some Application"


Sub UninstallProduct(sPartDisplayName)
On Error Resume Next

Dim oKeys, i, sDispName, sUninstall

Const sTOPKEY = "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall"

oKeys = EnumKeys(sTOPKEY, True)

For i = 0 to Ubound(oKeys)

sDispName = LCase(oWsh.RegRead(sTOPKEY & "\" & oKeys(i) & "\DisplayName"))

If Instr(sDispName, LCase(sPartDisplayName)) <> 0 Then

sUninstall = oWsh.RegRead(sTOPKEY & "\" & oKeys(i) & "\UninstallString")

If sUninstall <> "" Then oWsh.Run sUninstall, 5, True : Exit Sub

End If


End Sub


Function EnumKeys(Path, bSubKeys)

Dim oOutParam, oRegistry, oMethod, oInParam, sRoot, iRoot, i, oNames,sPath

Const HKEY_CLASSES_ROOT = &H80000000
Const HKEY_CURRENT_USER = &H80000001
Const HKEY_LOCAL_MACHINE = &H80000002
Const HKEY_USERS = &H80000003
Const HKEY_CURRENT_CONFIG = &H80000005

sRoot = Left(Path, Instr(Path,"\")-1)

sPath = Mid(Path, Instr(Path,"\")+1)

Select Case sRoot

Case "HKCR"


Case "HKCU"








End Select

Set oRegistry = GetObject("winmgmts:/root/default:StdRegProv")

Set oMethod = oRegistry.Methods_("EnumValues")
Set oInParam = oMethod.inParameters.SpawnInstance_()

oInParam.hDefKey = iRoot
oInParam.sSubKeyName = sPath

If Not bSubKeys Then

Set oOutParam = oRegistry.ExecMethod_("EnumValues", oInParam)


Set oOutParam = oRegistry.ExecMethod_("EnumKey", oInParam)

End If

Set oNames = oOutParam.Properties_("sNames")

Dim oSubKeys() : ReDim oSubKeys(-1) ' -1 signifies an valid but empty array.

If Not IsNull(oNames) then

Redim oSubKeys(UBound(oOutParam.Properties_("sNames")))

For i=0 To UBound(oOutParam.Properties_("sNames"))

oSubKeys(i) = oOutParam.Properties_("sNames")(i)


End If

EnumKeys = oSubKeys

End Function
Answered 02/21/2005 by: WiseUser
Fourth Degree Brown Belt

Please log in to comment
Also check out the Admin Script Editor "Uninstall Wizard" - http://www.adminscripteditor.com/wizards/view.asp?id=21

It looks at your system and provides uninstall scripts in the language of your choice based on those applications that support a silent uninstall. It requires that you install the Admin Script Editor, but it does work with the free trail: http://www.adminscripteditor.com/editor
Answered 02/21/2005 by: bkelly
Red Belt

Please log in to comment
Great! Thanks for the replies Gentlemen!!! Brenthunter2005, I am enumerating the keys. Thanks again Everyone!
Answered 02/21/2005 by: strakm
Senior Yellow Belt

Please log in to comment