Uninstall MSI if Installed for the Current User

This function takes an MSI product code as input and uninstalls the software if its installed for the current user (ProductState =5)

Sub UnInstPkg (StrProdCode)

Dim oWSHShell : Set oWSHShell = CreateObject("WScript.Shell")
Dim oMSI : Set oMSI = CreateObject("WindowsInstaller.Installer")
Dim UnInstVal : UnInstVal = 1

 Do While UnInstVal <> 0
  If oMSI.ProductState (StrProdCode) = 5 Then
   ReturnVal = oWSHShell.Run("MSIExec.exe /X " & StrProdCode & " /QB!-", 0, True)
   if Not (ReturnVal = 0 OR ReturnVal = 3010) then WScript.Quit ReturnVal
   UnInstPkg (StrProdCode)
  Else
   UnInstVal = 0
  End If

  Loop
End Sub