Const sDeleteProduct = "ReportPortal"
Const HKEY_CLASSES_ROOT  = &H80000000
Dim oReg, oShell, oSubKeys, sSubkey, sProduct, bFound

bFound = false
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")
Set oShell = WScript.CreateObject("WScript.Shell")
oReg.EnumKey HKEY_CLASSES_ROOT, "Installer\Products", oSubKeys

For Each sSubkey In oSubKeys
	sProduct = oShell.RegRead("HKEY_CLASSES_ROOT\Installer\Products\" & sSubkey & "\ProductName")
	'WSCript.Echo sProduct
	
	if InStr(sProduct,sDeleteProduct) <> 0 Then
		bFound = True
		
		If MsgBox("Uninstall " & sProduct & "?", vbYesNo) = vbYes Then
			DeleteProduct sSubkey
		End If
	End If
Next

If bFound = False Then
	Msgbox "Product not found: " & sDeleteProduct
End If

Sub DeleteProduct(sKey)
	On Error resume next

	oShell.RegDelete("HKEY_CLASSES_ROOT\Installer\Products\" & sSubkey & "\SourceList\Net\")
	oShell.RegDelete("HKEY_CLASSES_ROOT\Installer\Products\" & sSubkey & "\SourceList\Media\")
	oShell.RegDelete("HKEY_CLASSES_ROOT\Installer\Products\" & sSubkey & "\SourceList\")
	oShell.RegDelete("HKEY_CLASSES_ROOT\Installer\Products\" & sSubkey & "\")
	
	If err.Number <> 0 Then
		Msgbox err.Description
	Else
		Msgbox "Product is removed"
	End If
End Sub
