1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
   |  
Option Explicit 'all variables must be defined
Const REG_EXPAND_SZ = 2 
 
Dim oReg, oShell, sValue, sValueNames
Dim UninstallString, ProductCode, Valeur
Dim strComputer, OK
Dim strKeyPath, subkey, arrSubKeys
strComputer = "." 
OK = False
'********************************
'Enter Product Code Of The Application Here That You Want To Uninstall within the Bracket 
ProductCode = "{C6F5B6CF-609C-428E-876F-CA83176C021B}" '"{88C972E7-D7FC-40F3-9FE5-180957F37B45}"
 
'********************************
 
' Get scripting objects needed throughout script.
Set oShell = CreateObject("WScript.Shell")
 
'**************************
UninstallString = "MsiExec.exe /X{C6F5B6CF-609C-428E-876F-CA83176C021B}" '"MsiExec.exe /X{88C972E7-D7FC-40F3-9FE5-180957F37B45} /qn" & " /norestart"
 
Const HKLM = &H80000002
 
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _ 
                    strComputer & "\root\default:StdRegProv")
 
strKeyPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
oReg.EnumKey HKLM, strKeyPath, arrSubKeys
 
For Each subkey In arrSubKeys 
  ' Enumération des valeurs de type REG_EXPAND_SZ
  oReg.EnumValues HKLM, strKeyPath & "\" & subkey, sValueNames, REG_EXPAND_SZ
 
  If subkey = "{C6F5B6CF-609C-428E-876F-CA83176C021B}" Then ' Condition sur la sous-clé
      For Each sValue In sValueNames
           ' Recherche de la donnée de la valeur "UninstallString"
            oReg.GetExpandedStringValue HKLM , strKeyPath & "\" & subkey , "UninstallString", Valeur
             OK = LCase(Valeur) = LCase(UninstallString) ' Comparaison 
            If OK Then Exit For ' Si trouvé, on arrête la recherche
      Next
  End If
 
Next 
 'Ligne suivante mise en commentaire pour ne pas désinstaller
 'oShell.Run UninstallString, 1, True
 
 If OK Then
   MsgBox "Trouvé " & vbcrlf & vbcrlf & valeur & "  =  " & UninstallString
 Else 
   MsgBox "Pas trouvé"
 End If
 
Set oShell = Nothing
Set oReg = Nothing | 
Partager